For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
DocsAPI ReferenceSDKs
DocsAPI ReferenceSDKs
  • Introduction
    • Product Overview
    • Pricing
    • Model Explanation
    • Available Models
  • Guides
    • Quickstart
    • Authentication
    • BYOK
    • Dashboard Guide
    • Prompt Templates
    • Embeddings
    • RAG (Files & Search)
    • Audio
    • Images & Vision
    • Image Generation
    • Compare
    • Batch API
    • Auto Routing
    • Realtime Audio
  • SDKs
    • Node.js (TypeScript)
    • Python
    • Go
  • Infrastructure
    • Architecture
LogoLogo
On this page
  • Image Generation
  • Endpoint
  • Parameters
  • Streaming
  • Keep-alive chunk sequence
  • Response
  • Examples
  • Standard generation
  • Streaming
Guides

Image Generation

||View as Markdown|
Was this page helpful?
Edit this page
Previous

Images & Vision

Next

Compare

Built with

Image Generation

Mesh API exposes a standalone OpenAI-compatible image generation endpoint at POST /v1/images/generations, supporting models from OpenAI (gpt-image-*, dall-e-3) and Vertex AI (Imagen).

Endpoint

POST /v1/images/generations

Parameters

FieldTypeDescription
promptstringText description of the image. Required.
modelstringModel ID (e.g., openai/gpt-image-1, vertex/imagen-3). Required.
nintegerNumber of images to generate (1–10). Default: 1.
sizestringDimensions or aspect ratio (e.g., 1024x1024, 1792x1024). Default: auto.
qualitystringRendering quality: low, medium, high, hd, standard, or auto. Default: auto.
output_formatstringEncoding for the returned image: png, jpeg, or webp. OpenAI only.
streambooleanEnable SSE keep-alive / native streaming. Default: false.

Streaming

Setting stream: true returns a text/event-stream response that prevents the connection from closing during long-running generations.

The stream always ends with data: [DONE].

Keep-alive chunk sequence

data: {"id":"img-...","object":"image.chunk","created":...,"model":"...","data":[],"status":"processing"}
: ping
: ping
data: {"id":"...","object":"image.chunk","created":...,"data":[{"url":"..."}]}
data: [DONE]

Response

1{
2 "created": 1715356800,
3 "data": [
4 {
5 "url": "https://...",
6 "revised_prompt": "..."
7 }
8 ],
9 "background": "opaque",
10 "output_format": "webp",
11 "quality": "high",
12 "size": "1024x1024",
13 "usage": {
14 "prompt_tokens": 100,
15 "completion_tokens": 1000,
16 "total_tokens": 1100
17 }
18}

background, output_format, quality, size, and usage are only present when the upstream provider returns them. Vertex AI (Imagen) does not return token usage. Vertex AI always returns b64_json regardless of response_format.

Examples

Standard generation

$curl -X POST https://api.meshapi.ai/v1/images/generations \
> -H "Authorization: Bearer YOUR_MESH_API_KEY" \
> -H "Content-Type: application/json" \
> -d '{
> "model": "openai/gpt-image-1",
> "prompt": "A watercolor of a fox in a snowy forest",
> "n": 1,
> "size": "1024x1024",
> "quality": "high",
> "output_format": "webp"
> }'

Streaming

$curl -X POST https://api.meshapi.ai/v1/images/generations \
> -H "Authorization: Bearer YOUR_MESH_API_KEY" \
> -H "Content-Type: application/json" \
> -d '{
> "model": "openai/gpt-image-1",
> "prompt": "A watercolor of a fox in a snowy forest",
> "stream": true
> }'