Create image
Generate an image from a text prompt.
/v1/images/generationsJSON body. Unrecognized fields are forwarded to the provider as extension parameters. See Vendor extension fields.
curl http://localhost:8080/v1/images/generations \
-H "Authorization: Bearer $LLM_PROXY_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-image-1", "prompt": "A lighthouse at dusk", "size": "1024x1024"}'from openai import OpenAI
client = OpenAI(base_url="http://localhost:8080/v1", api_key="sk-your-proxy-key")
img = client.images.generate(model="gpt-image-1", prompt="A lighthouse at dusk")
print(img.data[0].url){
"created": 1718047200,
"data": [
{
"url": "https://…/lighthouse.png",
"revised_prompt": "A lighthouse at dusk, warm light"
}
],
"usage": {
"input_tokens": 50,
"output_tokens": 1240,
"input_tokens_details": {"text_tokens": 50, "image_tokens": 0}
}
}Request fields
prompt (required), model, n (1–12), quality, size, style, response_format (url default, or b64_json), user, background, moderation, output_format, output_compression, partial_images, stream.
size:auto, orWIDTHxHEIGHTwhere both edges ≥ 16 and divisible by 16, the larger edge ≤ 3840, and the aspect ratio within 1:3–3:1.n: the schema accepts 1–12 (the widest documented provider range). Providers apply their own caps; see Vendor extension fields.gpt-image-*models additionally receivebackground,moderation,output_compression,output_format,complexity,frame_count,frame_duration_ms,partial_images;response_formatandstyleare omitted for them.
Animated GIF and SVG output
GPT Image 2.6 (gpt-image-2.6-flare, gpt-image-2.6-sunburst) adds gif and svg to output_format on /v1/images/generations.
gif:frame_countis 2–64 (default 9) andframe_duration_msis 20–2000 (default 200; the provider rounds it to 10 ms).sizeisautoor aWIDTHxHEIGHTresolution whose edges are multiples of 16.svg:nmust be1.- Both formats reject
stream,partial_imagesandoutput_compressionwith 400invalid_request_error, and neither is available on/v1/images/edits, which keepspng,jpegandwebp. frame_countandframe_duration_msare GIF-only: sending either with anotheroutput_formatis a 400.
complexity (low, medium, high; upstream default high) controls how much planning the model does before rendering, and is forwarded for any gpt-image-* model.
Media bytes pass through unchanged: a GIF or SVG is exactly what the provider produced, delivered as b64_json or url depending on the request.
Vendor extension fields
Fields outside the OpenAI Images schema are passed through to the provider's request body, so upstream-specific options stay reachable without extra_body (which the OpenAI SDK offers for chat, not images).
qwen / qwen-intl (DashScope) accept:
image: a public image URL, a base64 data URL, or an array of either. Supplying it runs image-to-image; omitting it runs text-to-image.negative_prompt,seed,prompt_extend,prompt_extend_mode,enable_thinking,watermark: forwarded into DashScope'sparametersblock.- On
/v1/images/edits:color_palette,bbox_list,enable_sequential,thinking_mode.
qwen/qwen-intl per-model caps (violations return 400 invalid_request_error): n is 1–6 for qwen-image-* and 1–4 for wan* (1–12 with enable_sequential).
With server_params.unknown_fields_policy: error, the proxy rejects unknown fields instead of forwarding them, while keeping documented upstream fields for each provider working.
Response
{"created": <int>, "data":[{"url"|"b64_json", "revised_prompt"?}], …} with optional usage (input_tokens, output_tokens, input_tokens_details.{text_tokens,image_tokens}).
- Image responses have no
modelfield, and the proxy does not convert betweenurlandb64_json. You receive whatever the provider produced. stream: trueemits SSE eventsimage_generation.partial_image(withb64_json,partial_image_index) andimage_generation.completed, then[DONE].- There is no async/background image mode.
Provider support
openai, the openai-compatible family, gemini, and qwen providers can serve image requests. See the capability matrix and Vendor extension fields.
Related
curl http://localhost:8080/v1/images/generations \
-H "Authorization: Bearer $LLM_PROXY_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-image-1", "prompt": "A lighthouse at dusk", "size": "1024x1024"}'from openai import OpenAI
client = OpenAI(base_url="http://localhost:8080/v1", api_key="sk-your-proxy-key")
img = client.images.generate(model="gpt-image-1", prompt="A lighthouse at dusk")
print(img.data[0].url){
"created": 1718047200,
"data": [
{
"url": "https://…/lighthouse.png",
"revised_prompt": "A lighthouse at dusk, warm light"
}
],
"usage": {
"input_tokens": 50,
"output_tokens": 1240,
"input_tokens_details": {"text_tokens": 50, "image_tokens": 0}
}
}