API reference · API
Generate images (OpenAI wire format)
POST/v1/images/generationsAPI key
Served on the terms a completion is: the key's chat scope and policy, the account's credits with a hold at the worst case, and one metered usage row settled at what the upstream measured. A model with no published price, or one priced in a unit the endpoint does not report, is refused on house money with 503 pricing_unavailable and served on your own provider key. With no provider configured the answer is 503 upstream_unavailable. No fallback chain and no x402: a media request names one model and needs a key. An image from OpenRouter is charged the cost its answer reports; an OpenAI image is charged per token of each kind at OpenAI's list price. The hold reserves 8192 output tokens per image. A caller who disconnects does not cancel a generation that began: it is finished and metered.
Request body
application/json, required
| Field | Type | What it is |
|---|---|---|
| modelrequired | string | An image model: openai/gpt-image-* on the native OpenAI adapter, or any model OpenRouter's /images endpoint lists. GET /v1/models marks them with output_modalities image. At most 200 characters. |
| promptrequired | string | At most 32000 characters. |
| n | integer | From 1 to 10. |
| size | string | |
| quality | string | One of "auto", "low", "medium", "high", "standard", "hd". |
| background | string | One of "auto", "transparent", "opaque". |
| response_format | string | b64_json (default) or url. The gateway keeps no blob storage, so url answers a data: URL holding the image itself. One of "b64_json", "url". |
| output_format | string | One of "png", "jpeg", "webp". |
| output_compression | integer | From 0 to 100. |
| moderation | string | One of "auto", "low". |
| user | string | At most 256 characters. |
| aspect_ratio | string | OpenRouter only; named in x-antimatter-adjusted when the model is served elsewhere. |
| resolution | string | OpenRouter only, as aspect_ratio. One of "512", "1K", "2K", "4K". |
| stream | boolean | Refused when true: streamed generation is not offered. |
| partial_images | integer | Refused: streamed generation is not offered. From -9007199254740991 to 9007199254740991. |
Example
{
"model": "antimatter/auto",
"prompt": "Say hello in five words."
}Answer 200
The images, and the token counts where the upstream reported them.
Headers: x-antimatter-upstream, x-antimatter-model, x-antimatter-request-id, x-antimatter-byok, x-antimatter-adjusted, x-ratelimit-limit, x-ratelimit-remaining, x-ratelimit-reset
| Field | Type | What it is |
|---|---|---|
| created | integer | |
| data | array of object | |
| data[] | string | |
| data[] | string | A data: URL. |
| data[] | string | |
| usage | object | |
| usage. | integer | |
| usage. | integer | |
| usage. | integer |
Errors
- 400OpenAI shaped error.
- 401OpenAI shaped error.
- 402OpenAI shaped error.
- 403OpenAI shaped error.
- 404OpenAI shaped error.
- 413OpenAI shaped error.
- 429OpenAI shaped error.
- 502OpenAI shaped error.
- 503OpenAI shaped error.
- 504OpenAI shaped error.
Every error answers in one shape, with its type, code and the field it names. The whole list is in the docs' Errors section.