API reference

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

Request body fields
FieldTypeWhat it is
modelrequiredstringAn 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.
promptrequiredstringAt most 32000 characters.
nintegerFrom 1 to 10.
sizestring
qualitystringOne of "auto", "low", "medium", "high", "standard", "hd".
backgroundstringOne of "auto", "transparent", "opaque".
response_formatstringb64_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_formatstringOne of "png", "jpeg", "webp".
output_compressionintegerFrom 0 to 100.
moderationstringOne of "auto", "low".
userstringAt most 256 characters.
aspect_ratiostringOpenRouter only; named in x-antimatter-adjusted when the model is served elsewhere.
resolutionstringOpenRouter only, as aspect_ratio. One of "512", "1K", "2K", "4K".
streambooleanRefused when true: streamed generation is not offered.
partial_imagesintegerRefused: 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

Fields of the 200 answer
FieldTypeWhat it is
createdinteger
dataarray of object
data[].b64_jsonstring
data[].urlstringA data: URL.
data[].revised_promptstring
usageobject
usage.input_tokensinteger
usage.output_tokensinteger
usage.total_tokensinteger

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.

Antimatter