> ## Documentation Index
> Fetch the complete documentation index at: https://docs.prisme.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate images

> OpenAI-compatible image generation. The gateway resolves the model
(request `model`, else the org governance default, else the platform
default `config.defaults.image_generation`) and routes the call to the
provider (OpenAI, Azure OpenAI, Google Vertex Imagen).

**Size resolution.** Pass an abstract `aspect` + `tier`, or an explicit
pixel `size`. The gateway snaps it to a size listed in the model's
`capabilities.supported_sizes`; an exact supported `size` is kept as is.
Without a supported-sizes list, `size` is passed through (default
`1024x1024`). The size actually used is returned in `size`.

**Images are always returned as URLs.** When the provider only returns
base64 data, the gateway uploads it to Prisme.ai file storage and
returns a tokenised `url` instead, so `data[].b64_json` is never
present in the response.

**Governance.** Requires the `image-generation` model permission. A
model not allowed for the organization is either downgraded to the
governance fallback model (`soft_downgrade` quota policy) or refused
with `403 MODEL_NOT_ALLOWED`. A required upstream identity header that
would reach the provider empty is refused with
`403 HEADER_POLICY_VIOLATION`.




## OpenAPI

````yaml /api-reference/llm-gateway/swagger.yml post /v1/images/generations
openapi: 3.0.3
info:
  version: 1.0.0
  title: LLM Gateway API
  description: |
    Public REST API for the Prisme.ai LLM Gateway - OpenAI-compatible
    chat completions, embeddings and image generation/editing, a standard
    rerank endpoint, a managed model catalogue with governance overrides
    per organization, and quota status for users and organizations.

    The gateway abstracts multi-provider LLM access (OpenAI, Azure OpenAI,
    Anthropic, Google Vertex, AWS Bedrock, OpenAI-compatible providers) behind
    an OpenAI-compatible request/response shape. It enforces per-tenant
    governance (allowed models, default models, quotas) and emits analytics
    events (`analytics.llm.completion`) usable for cost and carbon reporting.

    This spec documents only the public REST surface (endpoints exposed via
    Prisme.ai workspace webhooks). Internal helpers (private automations
    prefixed with `_`) and load-test mocks are not part of the public contract.
  contact:
    name: Prisme.ai
    url: https://prisme.ai
servers:
  - url: https://{host}/v2/workspaces/slug:llm-gateway/webhooks
    description: Prisme.ai workspace webhooks
    variables:
      host:
        default: api.studio.prisme.ai
        description: API host (override for self-hosted or sandbox)
security:
  - BearerAuth: []
  - OrgApiKeyAuth: []
tags:
  - name: Completions
    description: OpenAI-compatible chat completions (with optional SSE streaming).
  - name: Embeddings
    description: OpenAI-compatible text embeddings.
  - name: Rerank
    description: >-
      Rerank documents by relevance to a query (standard rerank contract,
      LLM-as-reranker backend).
  - name: Images
    description: OpenAI-compatible image generation and image editing.
  - name: Models
    description: Model catalogue (CRUD + bulk replace + governance-aware listing).
  - name: Audio
    description: OpenAI-compatible speech-to-text (audio transcriptions).
  - name: Quotas
    description: >-
      Effective LLM quota limits and current usage, per user and per
      organization.
  - name: Defaults
    description: >-
      Resolved default models for completions / embeddings / image generation /
      transcription / file parsing.
  - name: Test
    description: Smoke-test reachability of a model through the gateway.
paths:
  /v1/images/generations:
    post:
      tags:
        - Images
      summary: Generate images
      description: |
        OpenAI-compatible image generation. The gateway resolves the model
        (request `model`, else the org governance default, else the platform
        default `config.defaults.image_generation`) and routes the call to the
        provider (OpenAI, Azure OpenAI, Google Vertex Imagen).

        **Size resolution.** Pass an abstract `aspect` + `tier`, or an explicit
        pixel `size`. The gateway snaps it to a size listed in the model's
        `capabilities.supported_sizes`; an exact supported `size` is kept as is.
        Without a supported-sizes list, `size` is passed through (default
        `1024x1024`). The size actually used is returned in `size`.

        **Images are always returned as URLs.** When the provider only returns
        base64 data, the gateway uploads it to Prisme.ai file storage and
        returns a tokenised `url` instead, so `data[].b64_json` is never
        present in the response.

        **Governance.** Requires the `image-generation` model permission. A
        model not allowed for the organization is either downgraded to the
        governance fallback model (`soft_downgrade` quota policy) or refused
        with `403 MODEL_NOT_ALLOWED`. A required upstream identity header that
        would reach the provider empty is refused with
        `403 HEADER_POLICY_VIOLATION`.
      operationId: createImage
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImageGenerationRequest'
      responses:
        '200':
          description: Generated images.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImagesResponse'
        '401':
          description: Missing or invalid authentication.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: >
            Missing `image-generation` permission (`FORBIDDEN`), model refused
            by

            the organization governance (`MODEL_NOT_ALLOWED`), or header-policy

            refusal (`HEADER_POLICY_VIOLATION`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        default:
          description: |
            Provider error, forwarded with the provider's HTTP status.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    ImageGenerationRequest:
      type: object
      properties:
        model:
          type: string
          maxLength: 256
          description: >-
            Image model id. Defaults to the org governance default, then the
            platform default.
        prompt:
          type: string
          description: Text description of the image to generate.
        size:
          type: string
          description: >-
            Explicit `WxH` pixel size. Kept as is when the model supports it,
            otherwise snapped (see `aspect` / `tier`).
          example: 1024x1024
        aspect:
          type: string
          enum:
            - square
            - portrait
            - landscape
          description: >-
            **Prisme.ai extension.** Abstract orientation, snapped to a size the
            model supports.
        tier:
          type: string
          enum:
            - small
            - medium
            - large
          description: >-
            **Prisme.ai extension.** Size tier within the orientation (default
            `medium`).
        style:
          type: string
          description: Provider style hint, forwarded to the provider when set.
        'n':
          type: number
          description: Number of images to generate (default 1).
        response_format:
          type: string
          enum:
            - url
            - b64_json
          description: |
            Format requested from the provider (default `url`). The response
            always carries URLs: base64 results are uploaded and replaced by a
            `url`.
        analytics_context:
          type: object
          description: >-
            **Prisme.ai extension.** Caller-supplied analytics context
            (`orgSlug`, `agent_id`, `user_id`, `context_id`,
            `agent_allowed_models`).
          additionalProperties: true
    ImagesResponse:
      type: object
      properties:
        created:
          type: integer
          description: Unix timestamp of the generation.
        model:
          type: string
          description: Model that produced the images (after governance resolution).
        data:
          type: array
          items:
            type: object
            properties:
              url:
                type: string
                description: >-
                  URL of the image (a tokenised Prisme.ai file URL when the
                  provider returned base64).
        size:
          type: string
          description: '**Prisme.ai extension.** Size actually used after resolution.'
      example:
        created: 1767225600
        model: gpt-image-1
        size: 1024x1024
        data:
          - url: https://api.studio.prisme.ai/v2/files/file-abc.png?token=token-123
    Error:
      type: object
      required:
        - error
      description: |
        Standard error envelope. `error` carries either a stable PascalCase
        identifier or a free-text label (legacy endpoints) - `code` is the
        canonical machine-readable identifier going forward.
      properties:
        error:
          type: string
          description: Stable PascalCase identifier or short error label.
        message:
          type: string
          description: Human-readable error message.
        code:
          type: string
          description: |
            Machine-readable error code. Observed values include
            `RATE_LIMITED`, `MODEL_NOT_ALLOWED`, `HEADER_POLICY_VIOLATION`,
            `MODEL_NOT_FOUND`,
            `MODEL_EXISTS`, `MISSING_MODEL_ID`, `MISSING_TYPE`, `INVALID_BODY`,
            `BULK_REPLACE_FAILED`,
            `INVALID_ITEMS`, `INVALID_DIMENSIONS`, `PAYLOAD_TOO_LARGE`,
            `METHOD_NOT_ALLOWED`, `PROVIDER_ERROR`, `PROVIDER_NO_RESPONSE`.
        details:
          description: Optional structured context (e.g. list of invalid items).
          additionalProperties: true
        status:
          type: integer
          description: HTTP status mirror, when present.
        retryAfter:
          type: integer
          description: Seconds to wait before retrying (rate-limit responses).
        provider:
          type: string
          description: Upstream provider name (provider-error responses).
        model:
          type: string
          description: Model id involved in the error (provider-error responses).
        provider_error_type:
          type: string
          description: Upstream provider's own error class name.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: |
        User-bound credential carrying an identity: either a session JWT
        or a user access token (`at:*`) generated from the user settings UI.
        Send as `Authorization: Bearer <token>`.
        Org API keys (`iak_*`) are **not** accepted here - they carry
        no user identity. Use the `x-prismeai-api-key` header instead
        (see `OrgApiKeyAuth`).
    OrgApiKeyAuth:
      type: apiKey
      in: header
      name: x-prismeai-api-key
      description: |
        Organization API key (`iak_{orgSlug}_{uuid}`). Unlike
        `Authorization: Bearer`, this credential is **not** tied to a user
        identity - it is bound to the org and its effective access is
        defined by the scopes / permission rules attached to it (it can
        be restricted to a single project, or kept broader).
        Send as `x-prismeai-api-key: iak_...`.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.