[Mac M2 Pro 12CPU, Ventura 13.6, Python 3.10.4]
DALL-E 3からAPIで使えるようになったので、早速試してみました。
生駒山近景を出力したところ存在しないロープウェイを含む景色でした。2回目は信仰の山らしく祠の画像でした。六甲山も出してみました。
どうも画のタッチが好みではありません。そこら辺を調整できれば、使い出がありそうです。
# openaiライブラリを導入済みの場合はアップグレードする(旧Verにはopenai.OpenAIがない)
pip install --upgrade openai
import os
from openai import OpenAI
# 環境変数からAPIキーを取得
api_key = os.getenv('CHATGPT_API_KEY')
if not api_key:
raise ValueError("OpenAI API Keyが環境変数に設定されていません")
# APIキーを設定
os.environ["OPENAI_API_KEY"] = api_key
client = OpenAI()
response = client.images.generate(
model="dall-e-3",
prompt="大阪府・奈良県にある生駒山の近景",
size="1024x1024",
quality="standard",
n=1,
)
image_url = response.data[0].url
print(image_url)


