# OpenRouter Image API — OpenAI: GPT Image 1 (openai/gpt-image-1) Guide for generating images with `openai/gpt-image-1` through OpenRouter's Image API. Docs: https://openrouter.ai/docs/guides/overview/multimodal/image-generation Model page: https://openrouter.ai/openai/gpt-image-1 Model discovery API: https://openrouter.ai/api/v1/images/models Endpoints (openai/gpt-image-1): https://openrouter.ai/api/v1/images/models/openai/gpt-image-1/endpoints Create an API key: https://openrouter.ai/settings/keys ## Endpoint POST https://openrouter.ai/api/v1/images Headers: - Authorization: Bearer $OPENROUTER_API_KEY - Content-Type: application/json ## Request fields (openai/gpt-image-1) - model: string (required) — `"openai/gpt-image-1"` - prompt: string (required) — text description of the desired image - aspect_ratio: "1:1" | "3:2" | "2:3" | "auto" (optional) — aspect ratio of the generated image - quality: "auto" | "low" | "medium" | "high" (optional) — rendering quality - background: "auto" | "transparent" | "opaque" (optional) — background treatment; transparent requires png or webp output - n: integer 1-10 (optional) — number of images to generate - input_references: array of up to 16 image references (optional) — reference images for image-to-image, as `{ "type": "image_url", "image_url": { "url": "…" } }` entries; the url is an https URL or a base64 data URL - output_compression: integer 0-100 (optional) — compression level for webp/jpeg output; ignored for png - stream: boolean (optional) — stream partial images as SSE events These are the generation parameters this model accepts between its providers; an unlisted value is rejected, and a listed one can still be refused by whichever provider serves the call. `provider` (routing preferences) is accepted on every request. ## Response ```json { "created": 1748372400, "data": [{ "b64_json": "", "media_type": "image/png" }], "usage": { "prompt_tokens": 0, "completion_tokens": 4175, "total_tokens": 4175, "cost": 0.04 } } ``` Base64-decode `data[i].b64_json` and write the bytes to a file; `media_type` gives the extension. `usage.cost` is the USD charge for the call. ## Examples ### Text to Image ```bash curl -X POST https://openrouter.ai/api/v1/images \ -H "Authorization: Bearer $OPENROUTER_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "openai/gpt-image-1", "prompt": "Editorial architectural photograph of a contemporary neighborhood storefront at blue hour, glowing warmly against the dusk. Above the entrance, a warm-white neon sign in flowing hand-bent cursive reads exactly \"OpenRouter\", the only text in the scene. Large windows reveal a cozy, lived-in interior: wood shelves styled with books and ceramics, lush trailing plants, and soft pendant lighting. Potted plants and a bicycle rest by the entrance, and golden light spills across the wet pavement in gentle reflections. Straight-on composition, realistic materials, quiet street with no people.", "n": 1, "quality": "high", "aspect_ratio": "3:2" }' ``` ## Errors Failures return `{"error": {"code": , "message": }}` with the HTTP status: - 400 — malformed body, a parameter or value this model does not accept, or input blocked by the provider's content moderation - 401 — missing or invalid API key - 402 — insufficient credits - 403 — spend limit reached, key disabled, or the model or provider is blocked for your account - 404 — unknown model, or no provider can serve the request - 413 — request body too large - 429 — rate limited; retry with backoff - 502 — the generation failed upstream; failed generations are not billed --- Canonical version of this document: https://openrouter.ai/openai/gpt-image-1/llms.txt