Skip to main content
Generate images from text prompts — or edit existing images — using models from OpenAI, Google Vertex AI, and more. The API is compatible with the OpenAI images endpoint, so existing integrations work without modification.

Generate an image

Response:

Request fields

Not all parameters are supported by every model. Support varies by provider — unsupported fields are silently ignored or return an error depending on the model. Check the model’s documentation or test with your target model before relying on a specific parameter.

Edit an image

Transform an existing image — edit it with a prompt (optionally guided by a mask) or remove its background — by uploading it to POST /v1/images/edits. Unlike generation, this endpoint uses multipart/form-data (file upload), not JSON.
Response:
gpt-image-1 always returns the result as a base64 data URI in the url field. Pass response_format=b64_json for a b64_json field instead (supported on DALL·E models).

Operations

The operation field selects what to do. Support varies by provider: Requesting an operation a provider doesn’t support returns 422. A provider with no image-edit support at all returns 501.
BytePlus supports edit only. remove_background is OpenAI-only.

Request fields

multipart/form-data:
The per-file caps sit under a hard 32 MiB ceiling on the whole request body, enforced at the edge — which is why the reference-image aggregate is 28 MiB rather than the sum of the per-file limits. An oversized request returns a plain HTML 413 page with no Mesh error envelope and no request ID. See Rate Limits & Spend Caps.

More examples

Remove a background:
Edit with multiple reference images (BytePlus Seedream):

Streaming

Some models support streaming image generation — partial image data is sent as the model renders it. Set "stream": true:
The response is a text/event-stream. Its main job is to keep the connection open during a long generation: the server emits an initial processing chunk, then SSE comment pings until the image is ready. The stream always ends with data: [DONE].

Keep-alive chunk sequence

Available models

Check GET /v1/models for the full live list of enabled image models and their pricing.