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:
GPT image and Google Vertex AI models return image bytes, not a hosted link, so with response_format: "url" the url field holds a data: URI. Other providers may return an https:// link.

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 with POST /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.
Response:
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

The operation 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.
The per-file caps sit under a hard 32 MiB ceiling on the whole request body, enforced at the edge. A JSON body carries every image as base64, about 4/3 of the file size, so it reaches that ceiling sooner than multipart. 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

Set "stream": true to get a text/event-stream instead of a single JSON response:
BytePlus Seedream 4.0, 4.5 and 5.0 (e.g. 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.