Skip to main content
OpenRouter provides a dedicated Image API for generating images from text prompts (and optional reference images). The API covers model discovery, per-endpoint capabilities, and generation. You can browse available models and pricing on the models page filtered by image output.

Model Discovery

Via the Image Models API

The dedicated image models endpoint lists every available image model with its capabilities:
Each entry in the data array includes:

Per-Endpoint Records

Each model may be served by multiple providers. To see the definitive capabilities, pricing, and passthrough options per endpoint:

Capability Descriptors

The supported_parameters map uses typed descriptors to describe what each request field accepts: An absent key means the parameter is unsupported by that endpoint.

Via the Models API

You can also discover image models through the general Models API:

On the Models Page

Visit the Models page and filter by output modalities to find models with image generation capabilities.

API Usage

Send a POST request to /api/v1/images with the model and prompt:

Response Format

Images are returned as base64-encoded bytes. The usage field reports token counts and cost when available. The media_type field is present whenever the format is identifiable (including image/png), and omitted only when it could not be determined:
For non-PNG outputs (e.g., JPEG, WebP, or SVG from Recraft vector models), media_type reflects the actual format:

Image Configuration Options

Resolution and Aspect Ratio

Control output dimensions with resolution, aspect_ratio, or the convenience size shorthand:
  • resolution — normalized tier (512, 1K, 2K, 4K). Concrete pixel dimensions are derived per-provider.
  • aspect_ratio — normalized ratio. Pass auto to let the provider choose. Common values include 1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3, 4:5, 5:4, and extended ratios like 1:2, 2:1, 1:4, 4:1, 1:8, 8:1, 9:21, 21:9. Providers clamp to their supported subset — check the model’s supported_parameters for accepted values.
  • size — convenience shorthand. Pass a tier ("2K") or explicit pixels ("2048x2048") and it gets normalized for the provider. A tier size is equivalent to setting resolution and combines with aspect_ratio. An explicit pixel size is authoritative — a mismatched resolution or aspect_ratio alongside it is rejected with a 400.
Check the model’s supported_parameters to see which values each endpoint accepts.

Quality and Output Format

  • qualityauto, low, medium, or high. Providers without a quality knob ignore this.
  • output_formatpng, jpeg, webp, or svg (vectorization models only; SVG markup is base64-encoded in b64_json).
  • backgroundauto, transparent, or opaque. transparent requires an alpha-capable format (png or webp).
  • output_compression — 0–100 for webp/jpeg. Ignored for png.

Multiple Images

Request up to 10 images per call with n:
Not all providers support n > 1. Check the model’s supported_parameters for availability.

Image-to-Image (Reference Images)

Pass reference images to guide generation via input_references:
Reference images can be HTTP(S) URLs or base64 data URLs. The number of references accepted varies by provider.

Provider Routing

When a model has multiple providers, use the provider object to choose which endpoints can serve the request:
The Image API supports these routing fields:
  • only — allow only the listed provider slugs.
  • order — try providers in the listed order.
  • ignore — exclude the listed provider slugs.
  • sort — sort eligible endpoints by price, throughput, or latency.
  • allow_fallbacks — when false, stop after the primary provider instead of trying another eligible provider.
Use provider_tag from the per-endpoint records as the base provider slug. See Provider Routing for the routing behavior shared across OpenRouter APIs.

Provider-Specific Options

Pass provider-specific parameters through provider.options, keyed by the provider slug from the endpoints API:
The allowed_passthrough_parameters field in each endpoint record lists which keys are accepted.

Streaming Image Generation

Models that support native SSE streaming (supports_streaming: true in the discovery API) can return partial images as they’re generated:
The response is an SSE stream with three event types: Partial image — emitted as each partial render becomes available:
Completed — emitted when the final image is ready. The media_type field is present whenever the format is identifiable:
For non-PNG outputs (e.g., SVG from Recraft vector models), media_type reflects the actual format:
The usage object in the completed event includes cost (USD), matching the buffered response shape. Error — emitted if generation fails mid-stream:
The stream terminates with data: [DONE].

Billing and Cancellation

Image generation billing is all-or-nothing. A generation is either completed and billed in full, or it fails and is not billed — there is no partial or fractional image billing. This differs from chat completions, where a cancelled stream still bills for the tokens produced before cancellation.
  • Completed generations are billed for the full image output based on the endpoint’s pricing.
  • Failed or cancelled generations are not billed. When a generation does not complete, the request returns a 502 Bad Gateway rather than a partial result, and no charge is recorded.
If a client disconnects mid-generation, the upstream provider may still finish rendering the image and charge OpenRouter for it. Regardless, the client only ever observes one of two outcomes: a fully-billed result, or an error. OpenRouter does not attempt to bill the user for work they did not receive. For streaming requests, any partial preview images delivered before the stream ends do not create partial charges. Billing keys off completion of the final image, so a stream that terminates early (client disconnect or mid-stream error) is billed exactly as a failed generation: not at all.

Request Parameters

Use the Image Models API to check which parameters each model and endpoint supports.