Generate an image
- curl
- Python
response_format: "url" the url field holds a data: URI. Other providers may return an https:// link.
Request fields
Edit an image
Transform an existing image withPOST /v1/images/edits: edit it with a prompt (optionally guided by a mask), remove its background, upscale, outpaint, inpaint, mix or reframe it. Send either multipart/form-data (file uploads, as below) or application/json with each image as a data:image/<fmt>;base64,... string (or a {"url": "data:..."} object). Remote http(s) image URLs are rejected with 422, because Mesh does not fetch images.
- curl
- Python
GPT image and Vertex AI models return the result as a base64
data: URI in the url field. Pass response_format=b64_json to get the raw base64 in a b64_json field instead.Operations
Theoperation field selects what to do. Support is per model: each model lists the operations it serves in image_operations on GET /v1/models.
Requesting an operation the model doesn’t support returns
422. A provider with no image-edit support at all returns 501.
Request fields
multipart/form-data:
Size caps. Each image is capped at 20 MB, lower for some providers: BytePlus 4.7 MB, Gemini and Imagen 7 MB, Grok Imagine via OpenRouter 10 MB. Masks are capped at 4 MB on OpenAI, Azure and Imagen. All reference images together are capped at 20 MB. An oversized file returns
422.
More examples
Remove a background:Streaming
Set"stream": true to get a text/event-stream instead of a single JSON response:
byteplus/seedream-5-0) stream natively, in BytePlus’s own event shape. Each finished image arrives as an image_generation.partial_succeeded event with url or b64_json at the top level of the event, not under data[]. An image that fails arrives as image_generation.partial_failed. The stream ends with image_generation.completed, which carries usage; there is no data: [DONE].
For every other model the stream keeps the connection open during a long generation: the server emits an initial processing chunk, then SSE comment pings every 15 seconds until the image is ready, then one chunk with the result in data[], then data: [DONE].
Keep-alive chunk sequence
Available models
Check
GET /v1/models for the full live list of enabled image models, their pricing, and each model’s image_operations.