Image Generation via Chat
Image generation over the /v1/chat/completions route using OpenAI’s multimodal chat schema. As of July 28, 2026 the Wan 2.7 image models have moved to /v1/images/generations; seedream-4-5-251128 is the remaining model configured on this route.
content array containing a text prompt, and AIsa returns generated images as {type: "image"} parts inside choices[].message.content[].
generateContent requests use /v1beta/models/{model}:generateContent.Supported models
Request
The request schema is the samePOST /v1/chat/completions you already use for text — the only differences are which model you pass and how content is structured.
Critical rule: messages[].content must be an array of typed parts. Passing a plain string returns 400 invalid_parameter_error with the message "Input should be a valid list: messages[*].content".
Request fields
Response shape
- One choice per image. If
n=4, you get 4 entries inchoices. - Every
choice.message.contentis an array with a single{ "type": "image", "image": "..." }part. imageis a short-lived URL (download it soon) or base64 data, depending on your workspace configuration.usage.total_tokensreflects the small token cost of the request framing — billing is per-image at the rate in the table above, not per token.
Image-to-image
Prepend animage_url part to the content array and follow it with a text instruction. For the Wan models this workflow now lives on POST /v1/images/edits:
Why the playground shows the Chat Completions path
The playground sends exactly the samePOST /v1/chat/completions request the standard OpenAI Chat endpoint uses — only the model and content shape are tuned for images. Your existing OpenAI-compatible SDK code works without modification; just swap the model and content shape.
Common 4xx causes
400 invalid_parameter_error — Input should be a valid list: messages[*].content—contentwas passed as a string; wrap in an array of typed parts.400referencingmessages— you sent the Gemini-stylecontents/parts. Usemessageswith OpenAI multimodal parts.400 model_route_not_supported— the model does not serve this endpoint. The error body lists the routes it does serve;wan2.7-image,wan2.7-image-pro,seedream-5-0-260128, andgpt-image-2all belong on/v1/images/generations.502 no available channel— the route exists but the upstream has no capacity right now. Retry, or use an image model on/v1/images/generations.500 model_not_found— your workspace isn’t provisioned for this model family. Contact support.
Related
OpenAI Chat
Gemini generateContent
Media Gen skill
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Image-generation model on the chat route. seedream-4-5-251128 is billed at $0.036 per request. Wan and gpt-image-2 models use /v1/images/generations instead.
seedream-4-5-251128 Conversation messages. Image prompts go in the last user message's content array as {type: "text"} parts.
Number of images to generate. Each image is billed separately; pass 1 unless you want candidates.
x >= 1Response
Images generated. Returned as Chat Completion with message.content[] image parts.