---
title: "Generate image"
method: POST
path: "/images/generations"
tags: ["Images"]
---

# Generate image

`POST /images/generations`

Generate images from verified image-generation deployments. OpenAI-compatible response shape. The gateway does not replay-cache this operation.

## Request body

- ImageGenerationRequest
  - `model` string, required
  - `prompt` string, required
  - `n` integer
  - `size` string
  - `response_format` 'url' | 'b64_json'

## Response `200`

Image generation response

- ImageGenerationResponse
  - `created` integer, required
  - `data` object[], required
    - `url` string
    - `b64_json` string
    - `revised_prompt` string
  - `usage` Usage
    - `cost` number — The calculated cost of this request in US dollars, to eight decimals: the settlement formula over the tokens the provider reported. Present on hosted models; absent on workspace deployments. 0 during a promotional free window and for a response with no billable output. runinfra.cost_microcents is the canonical integer.
    - `prompt_tokens` integer
    - `completion_tokens` integer
    - `total_tokens` integer
    - `prompt_tokens_details` object — Present on every hosted model response. cached_tokens is the count of input tokens billed at the cached input rate, the figure the cost was computed with; 0 when nothing was billed as cached, including a response that settled at zero and a model whose cache is shared across tenants. runinfra.cached_input_tokens carries the same number.
      - `cached_tokens` integer
    - `runinfra` RunInfraUsageMetadata
      - `cost_microcents` integer — The calculated cost of this request in microcents (one cent is 1,000,000 microcents), the ledger unit settlement uses; the canonical figure. usage.cost is this value in dollars. The balance is debited in whole cents with sub-cent carry, so a single debit can differ from this by less than a cent.
      - `cached_input_tokens` integer — The count of input tokens billed at the cached input rate on this request, the same number as usage.prompt_tokens_details.cached_tokens. Present on every hosted model response; 0 when nothing was billed as cached.
      - `output_token_accounting` RunInfraOutputTokenAccounting
        - `visible_answer_tokens` 0, required — Final-answer token count classified by the RunInfra proxy for an all-empty generation-limit outcome.
        - `non_answer_completion_tokens` integer, required — Provider-reported completion tokens when the response produced no final answer.
        - `sources` object, required
          - `visible_answer_tokens` 'proxy_classified', required
          - `non_answer_completion_tokens` 'provider_reported', required

## Other responses

- `400` — Malformed request
- `401` — Missing or invalid API key
- `402` — Insufficient credits
- `403` — Key scope mismatch or plan limit exceeded
- `404` — Model or deployment not found
- `409` — Idempotency conflict
- `429` — Rate limit exceeded
- `500` — Unexpected gateway error
- `502` — Upstream serving backend transient failure
- `503` — Endpoint stopped, provisioning, or at capacity
- `504` — Gateway timeout

---

[API](https://skmtc.dev/runinfra/apis/runinfra-api.md) · [All operations](https://skmtc.dev/runinfra/apis/runinfra-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/runinfra/runinfra-api/revisions/dbd314122f80/schema)
