문서 · 연동
이미지 생성
POST /v1/images/generations creates images from a text prompt. Pick a model of type "Image" from the catalog.
본문은 현재 영어로만 제공됩니다.
curl https://<your-endpoint>/v1/images/generations \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-1",
"prompt": "A lighthouse on a cliff at sunset, watercolor",
"size": "1024x1024"
}'Common parameters
| Parameter | Description |
|---|---|
model | Required. An image model ID |
prompt | Required. What to draw — be specific |
size | For example 1024x1024; allowed values depend on the model |
n | Number of images |
Supported sizes, counts and return format (
url or b64_json) vary by model — check the model page. Returned URLs are usually temporary, so download them promptly.Saving the result
import base64
from openai import OpenAI
client = OpenAI(base_url="https://<your-endpoint>/v1", api_key="YOUR_API_KEY")
img = client.images.generate(
model="gpt-image-1",
prompt="A minimalist poster of a mountain lake, flat colors",
size="1024x1024",
n=1,
)
item = img.data[0]
if item.b64_json: # some models return base64
open("out.png", "wb").write(base64.b64decode(item.b64_json))
else: # others return a temporary URL; download it promptly
print(item.url)Image models may be billed per request or per token — see Pricing.