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

# Criar decisões

> **Beta.** Evaluate content against named questions and receive structured answers, probabilities, and usage costs. Send the content as `state` and define each entry in `questions` as:

- `noul`: estimate the probability that a statement is true.
- `choice`: select an option from a set.
- `score`: rate the content on an ordered scale.
- `box`: locate one target in an image and return its bounding box. Beta, TypeSafe `jev-preview` only.

Instructions and criteria accept strings or structured JSON. TypeSafe models also accept inline images through `assets` (beta).

Use a native decision model or a supported chat model. Configure ordered `fallbacks`, optional `retry`, `timeout.call_timeout` in milliseconds, and an exact-match `cache`. Each retry and fallback gets a fresh timeout; when `retry` is omitted, the gateway retries twice before moving to the next fallback. The response identifies the model that answered.

Requires the `classify` API-key permission. PII plugins and guardrails are not applied. See the [Decisions guide](/ai-gateway/features/decisions) for supported models, probability interpretation, and refusals.

Consulte [URLs e autenticação HTTP](/docs/pt-BR/reference/base-urls.md) e a referência da API para os formatos completos de solicitação e resposta.

> [!NOTE]
>
> **Guia relacionado**: consulte o [guia de Decisions](/docs/pt-BR/ai-gateway/features/decisions.md) para exemplos, fallbacks, timeouts, retries, cache e atribuição de identidade. A requisição exige a permissão de chave de API `classify`.


## OpenAPI

````yaml post /v3/router/decisions
openapi: 3.1.0
info:
  title: Toqan Router API
  version: '2.0'
  description: Toqan Router API documentation
servers:
  - url: https://router.toqan.ai/eu
    description: Frankfurt (Europe)
  - url: https://router.toqan.ai/br
    description: São Paulo (Brazil)
security:
  - ApiKey: []
tags:
  - description: >-
      API keys authenticate programmatic access to the workspace. They expose
      opaque tokens, per-domain access grants, and budget and rate-limit
      constraints.
    name: API keys
  - name: Logs
    description: >-
      OpenTelemetry log query API. Search, filter, aggregate, and facet log
      records ingested via OTLP.
  - name: Reporting
    description: >-
      GenAI reporting API over canonical analytics rollups. Accepts a metric
      name, time range, grain, group-by, and filters; returns a typed time
      series and optional totals.
  - name: Telemetry
    description: >-
      Unified query envelope for traces, metrics, and logs. One request shape,
      one filter dialect, and one response shape per source, validated by a
      per-source registry.
  - name: Traces
    description: >-
      Query and inspect ingested trace data: search trace summaries, aggregate
      metrics, and read individual traces and their spans.
  - name: Views
    description: Saved filters and columns for workspace observability pages.
  - description: List models available through the AI Router.
    name: Models
  - name: Alerts
    description: >-
      Alerts evaluate a telemetry metric on a fixed interval and fire
      notifications through notifiers when the value breaches a threshold. Each
      breach opens a trigger that tracks the incident until the value recovers.
  - name: Annotation Queues
    description: Annotation queues collect spans for human review.
  - name: Budgets
    description: >-
      Budgets govern spend, token usage, and request rate across six scopes:
      workspace, project, identity, API key, provider, and model. Every
      applicable budget is enforced, and the most restrictive limit applies per
      dimension.
  - name: Files
    description: File upload and retrieval operations.
  - name: Guardrail Rules
    description: >-
      Guardrail Rules conditionally enforce evaluators and plugins for AI
      Gateway traffic. Rules may be scoped to a project or the whole workspace.
  - name: Identities
    description: >-
      Identities represent end users from your system for usage and engagement
      tracking.
  - name: Management keys
    description: >-
      Management keys are workspace-scoped credentials that authenticate
      programmatic access to workspace administration surfaces (API keys,
      budgets). Unlike project-scoped API keys, a management key always operates
      at the workspace level.
  - name: MCP Gateway
    description: >-
      Register upstream MCP servers, discover and sync their tools, and assemble
      gateways that expose a curated tool surface to MCP clients.
  - name: Model Catalog
    description: >-
      Browse the Toqan Router model catalog: every model Toqan Router offers,
      across every provider, with pricing, capabilities and benchmark data. List
      endpoints only return models that are not deprecated. This API is public,
      requires no authentication, and is rate limited to 120 requests per minute
      per IP. Responses carry a 5-minute cache-control max-age.
  - name: Monitors
    description: >-
      Monitors are custom observability dashboards for traces, runtime metrics,
      and logs. Each monitor holds widgets that chart one telemetry query. List
      the metrics, operations, and dimensions available to your workspace with
      `GET /v3/telemetry/capabilities`, or start from a preset with `GET
      /v2/monitors/presets`.
  - name: Notifiers
    description: Notifier destinations used to send delivery and workflow notifications.
  - name: Routing Rules
    description: >-
      Routing Rules conditionally select models and enforce request plugins for
      AI Gateway traffic. Rules are evaluated by ascending priority and may be
      scoped to a project or the whole workspace.
  - name: Threads
    description: Threads group related trace invocations and their aggregate usage
  - name: Smart Routers
    description: >-
      Create and manage workspace Smart Routers. A Smart Router selects a model
      from an eligible pool for each request according to a quality, balanced,
      or cost profile.
  - name: Responses
  - name: Embeddings
  - description: Beta. Run typed classification questions against a classify model.
    name: Classify
  - description: Beta. Run classification decisions with the classify contract.
    name: Decisions
  - description: >-
      Run large offline workloads as JSONL batches and download
      OpenAI-compatible result files.
    name: Batches
paths:
  /v3/router/decisions:
    post:
      tags:
        - Decisions
      summary: Decisions
      description: >-
        **Beta.** Evaluate content against named questions and receive
        structured answers, probabilities, and usage costs. Send the content as
        `state` and define each entry in `questions` as:


        - `noul`: estimate the probability that a statement is true.

        - `choice`: select an option from a set.

        - `score`: rate the content on an ordered scale.

        - `box`: locate one target in an image and return its bounding box.
        Beta, TypeSafe `jev-preview` only.


        Instructions and criteria accept strings or structured JSON. TypeSafe
        models also accept inline images through `assets` (beta).


        Use a native decision model or a supported chat model. Configure ordered
        `fallbacks`, optional `retry`, `timeout.call_timeout` in milliseconds,
        and an exact-match `cache`. Each retry and fallback gets a fresh
        timeout; when `retry` is omitted, the gateway retries twice before
        moving to the next fallback. The response identifies the model that
        answered.


        Requires the `classify` API-key permission. PII plugins and guardrails
        are not applied. See the [Decisions
        guide](/ai-gateway/features/decisions) for supported models, probability
        interpretation, and refusals.
      operationId: CreateDecisions
      requestBody:
        content:
          application/json:
            examples:
              fallback_retry_identity:
                summary: Decisions with fallbacks, retries and identity
                value:
                  fallbacks:
                    - model: openai/gpt-5.6-luna
                  identity:
                    id: customer-demo
                    display_name: Sample customer
                  model: openai/gpt-6-luna
                  questions:
                    positive:
                      criteria:
                        'false': The customer is unhappy.
                        'true': The customer is happy.
                      instructions: Is the sentiment positive?
                      type: noul
                    rating:
                      criteria:
                        - Negative
                        - Neutral
                        - Positive
                      instructions: Rate sentiment.
                      type: score
                    sentiment:
                      criteria:
                        negative: Negative sentiment
                        neutral: null
                        positive: Positive sentiment
                      instructions: Classify sentiment.
                      type: choice
                  retry:
                    count: 2
                    on_codes:
                      - 429
                      - 502
                      - 503
                      - 504
                  state: 'The customer says: I love this product. It is wonderful!'
                  timeout:
                    call_timeout: 2000
              openai_inline_image:
                description: >-
                  A small self-contained PNG. Replace it with your own base64
                  image data URL.
                summary: Classify an inline image with OpenAI Decisions
                value:
                  model: openai/gpt-6-luna
                  questions:
                    contains_text:
                      instructions: Does the image contain text?
                      type: noul
                  state:
                    - content:
                        - text: Evaluate this image.
                          type: input_text
                        - image_url: >-
                            data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAACLSURBVHgBdY8NDYAgEIXBBEQgAhG0gRGMYBNtoA2M4EygDYygDfCxvdMbk7d9A453f8ZQMcYAWuBVzIHujeGyxE8nYz7dJWYl01p749zxDKABEzhYfDNaMPZSAUymJLZLuvSsSVUhx4G7VM2xpSzQ5YYhLUHDCGoad47ixXjxY84qi1a9QPgZpdYLPVkbtsfywz3jAAAAAElFTkSuQmCC
                          type: input_image
                      role: user
              openai_text:
                summary: Classify text with OpenAI Decisions
                value:
                  model: openai/gpt-6-luna
                  questions:
                    positive:
                      criteria:
                        'false': The customer is unhappy.
                        'true': The customer is happy.
                      instructions: Is the sentiment positive?
                      type: noul
                    rating:
                      criteria:
                        - Negative
                        - Neutral
                        - Positive
                      instructions: Rate sentiment.
                      type: score
                    sentiment:
                      criteria:
                        negative: Negative sentiment
                        neutral: null
                        positive: Positive sentiment
                      instructions: Classify sentiment.
                      type: choice
                  state: 'The customer says: I love this product. It is wonderful!'
              support_ticket:
                summary: Classify a support message
                value:
                  model: typesafe/jev-latest
                  questions:
                    is_complaint:
                      instructions: Is the customer complaining?
                      type: noul
                    severity:
                      criteria:
                        - Minor
                        - Moderate
                        - Severe
                      instructions: How severe is the issue?
                      type: score
                    topic:
                      criteria:
                        delivery: Shipping or delivery issues
                        other: null
                        product: Product quality
                      instructions: What is the message mainly about?
                      type: choice
                  state: The parcel arrived two days late and the box was crushed.
              typesafe_image_box:
                description: >-
                  Beta. Replace data_base64 with your own PNG or JPEG of 256 to
                  1568 px per side.
                summary: Locate an object in an image with TypeSafe
                value:
                  assets:
                    kitchen-photo:
                      type: image
                      data_base64: <base64 JPEG>
                      format: jpg
                  model: typesafe/jev-preview
                  questions:
                    mug:
                      instructions: the coffee mug in `photo`
                      type: box
                    mug_visible:
                      instructions: Is there a coffee mug in `photo`?
                      type: noul
                  state:
                    photo: kitchen-photo
            schema:
              additionalProperties: false
              properties:
                assets:
                  additionalProperties:
                    $ref: '#/components/schemas/ClassifyAsset'
                  description: >-
                    Beta, TypeSafe models only. Inline images keyed by a
                    reference string. Write the reference in state, instructions
                    or criteria wherever the image belongs; every asset must be
                    referenced. Required for box questions.
                  type: object
                cache:
                  $ref: '#/components/schemas/ClassifyCacheConfig'
                  description: >-
                    Exact-match response cache for this request. An identical
                    request body from the same workspace and project is served
                    from the stored response, with the X-Cache header reporting
                    HIT or MISS.
                fallback_on_codes:
                  description: >-
                    HTTP status codes that trigger fallback. Defaults to
                    [408,429,500,502,503,504,529]. Each code must be unique and
                    between 400 and 599.
                  items:
                    format: int64
                    type: integer
                  maxItems: 20
                  type:
                    - array
                    - 'null'
                fallbacks:
                  description: >-
                    Up to 10 fallback models in order. The gateway retries a
                    model for matching error codes before trying the next model.
                    Every model must support classification and satisfy access
                    checks. Requests with images in state require native OpenAI
                    image-capable fallbacks; requests with assets or box
                    questions require TypeSafe fallbacks.
                  items:
                    $ref: '#/components/schemas/FallbackConfig'
                  maxItems: 10
                  type:
                    - array
                    - 'null'
                identity:
                  $ref: '#/components/schemas/ResponseIdentity'
                  description: The identity to attach to the trace.
                metadata:
                  additionalProperties:
                    type: string
                  description: Key-value metadata attached to the trace.
                  type: object
                model:
                  description: >-
                    ID of a model that supports native or emulated classify,
                    including openai/gpt-6-luna.
                  type: string
                name:
                  type: string
                  description: >-
                    The name to display on the trace. If not specified, the
                    default system name will be used.
                prompt_cache_key:
                  description: >-
                    Native OpenAI only. Partitions reuse of shared input across
                    requests.
                  maxLength: 64
                  type: string
                prompt_cache_options:
                  $ref: '#/components/schemas/ClassifyPromptCacheOptions'
                  description: >-
                    Native OpenAI prompt caching controls. Separate from the
                    gateway exact-match response cache.
                questions:
                  additionalProperties:
                    oneOf:
                      - description: >-
                          Answers with a probability between 0 and 1 that the
                          statement holds.
                        properties:
                          criteria:
                            description: Optional descriptions of what true and false mean.
                            properties:
                              'false':
                                anyOf:
                                  - title: String
                                    type: string
                                  - additionalProperties: true
                                    title: Object
                                    type: object
                                  - items: {}
                                    title: Array
                                    type: array
                                description: >-
                                  What false means. A string, an object or an
                                  array.
                              'true':
                                anyOf:
                                  - title: String
                                    type: string
                                  - additionalProperties: true
                                    title: Object
                                    type: object
                                  - items: {}
                                    title: Array
                                    type: array
                                description: >-
                                  What true means. A string, an object or an
                                  array.
                            type: object
                          instructions:
                            anyOf:
                              - title: String
                                type: string
                              - additionalProperties: true
                                title: Object
                                type: object
                              - items: {}
                                title: Array
                                type: array
                            description: >-
                              The evaluation prompt for this question. A string,
                              an object or an array. Native OpenAI also accepts
                              arrays of input_text, input_image and input_json
                              parts. Question parts cannot contain prompt cache
                              breakpoints.
                          type:
                            enum:
                              - noul
                            type: string
                        required:
                          - type
                          - instructions
                        title: NoulQuestion
                        type: object
                      - description: >-
                          Picks one of the given options and returns the
                          probability of each.
                        properties:
                          criteria:
                            additionalProperties:
                              anyOf:
                                - title: String
                                  type: string
                                - additionalProperties: true
                                  title: Object
                                  type: object
                                - items: {}
                                  title: Array
                                  type: array
                                - title: 'Null'
                                  type: 'null'
                              description: The option description, or null.
                            description: >-
                              Options keyed by name, each mapped to a
                              description or null. A description can be a
                              string, an object or an array.
                            minProperties: 1
                            type: object
                          instructions:
                            anyOf:
                              - title: String
                                type: string
                              - additionalProperties: true
                                title: Object
                                type: object
                              - items: {}
                                title: Array
                                type: array
                            description: >-
                              The evaluation prompt for this question. A string,
                              an object or an array. Native OpenAI also accepts
                              arrays of input_text, input_image and input_json
                              parts. Question parts cannot contain prompt cache
                              breakpoints.
                          type:
                            enum:
                              - choice
                            type: string
                        required:
                          - type
                          - instructions
                          - criteria
                        title: ChoiceQuestion
                        type: object
                      - description: >-
                          Places the state on an ordered scale and returns the
                          probability of each level.
                        properties:
                          criteria:
                            description: >-
                              Ordered level descriptions from lowest to highest.
                              At least two levels. Each level can be a string,
                              an object or an array.
                            items: {}
                            minItems: 2
                            type: array
                          instructions:
                            anyOf:
                              - title: String
                                type: string
                              - additionalProperties: true
                                title: Object
                                type: object
                              - items: {}
                                title: Array
                                type: array
                            description: >-
                              The evaluation prompt for this question. A string,
                              an object or an array. Native OpenAI also accepts
                              arrays of input_text, input_image and input_json
                              parts. Question parts cannot contain prompt cache
                              breakpoints.
                          type:
                            enum:
                              - score
                            type: string
                        required:
                          - type
                          - instructions
                          - criteria
                        title: ScoreQuestion
                        type: object
                      - description: >-
                          Beta, TypeSafe jev-preview only. Locates one target in
                          an image from assets and returns its bounding box.
                          Always returns a box; pair it with a noul question to
                          check presence.
                        properties:
                          instructions:
                            anyOf:
                              - title: String
                                type: string
                              - additionalProperties: true
                                title: Object
                                type: object
                              - items: {}
                                title: Array
                                type: array
                            description: >-
                              The evaluation prompt for this question. A string,
                              an object or an array. Native OpenAI also accepts
                              arrays of input_text, input_image and input_json
                              parts. Question parts cannot contain prompt cache
                              breakpoints.
                          type:
                            enum:
                              - box
                            type: string
                        required:
                          - type
                          - instructions
                        title: BoxQuestion
                        type: object
                  description: >-
                    Typed questions keyed by an identifier of your choice. Each
                    answer is returned under the same key. Native OpenAI accepts
                    1 to 400 questions.
                  minProperties: 1
                  type: object
                retry:
                  $ref: '#/components/schemas/ClassifyRetryConfig'
                  description: Retry configuration for the request.
                state:
                  anyOf:
                    - title: String
                      type: string
                    - additionalProperties: true
                      title: Object
                      type: object
                    - items: {}
                      title: Array
                      type: array
                  description: >-
                    The content to evaluate. A string, an object or an array.
                    For TypeSafe models, reference images declared in assets by
                    writing their reference string. Native OpenAI accepts
                    messages and function/custom-tool history. User messages
                    support input_text, input_image and input_json; images can
                    use inline base64 data URLs or public HTTP(S) URLs. At most
                    128 images across state and question instructions. Shared
                    text/image parts support explicit prompt_cache_breakpoint
                    markers. File IDs, audio, item references and bare content
                    parts are unsupported. Other objects and arrays are
                    serialized as text.
                timeout:
                  $ref: '#/components/schemas/ClassifyTimeoutConfig'
                  description: >-
                    Timeout for each model call, including every retry and
                    fallback. A timed-out call returns 408 and advances to the
                    next fallback after configured retries are exhausted.
              required:
                - model
                - state
                - questions
              type: object
        required: true
      responses:
        '200':
          content:
            application/json:
              examples:
                openai_answers:
                  summary: OpenAI Decisions answers and usage
                  value:
                    model: openai/gpt-6-luna
                    answers:
                      positive:
                        type: noul
                        noul: 1
                      rating:
                        type: score
                        score: 2
                        legend:
                          '0': Negative
                          '1': Neutral
                          '2': Positive
                        probabilities:
                          '0': 0
                          '1': 0
                          '2': 1
                        confidence: 1
                      sentiment:
                        type: choice
                        choice: positive
                        probabilities:
                          negative: 0
                          neutral: 0
                          positive: 1
                        confidence: 1
                    usage:
                      input_tokens_details:
                        cached_tokens: 0
                        cache_write_tokens: 0
                      input_tokens: 408
                      output_tokens: 0
                      input_cost: 0.0000408
                      output_cost: 0
                      total_cost: 0.0000408
                partial_refusal:
                  description: >-
                    Illustrative response. A provider may refuse one question
                    while answering the rest. Refusals have no scored fields.
                  summary: One question is refused
                  value:
                    model: openai/gpt-6-luna
                    answers:
                      positive:
                        type: refusal
                      rating:
                        type: score
                        score: 2
                        legend:
                          '0': Negative
                          '1': Neutral
                          '2': Positive
                        probabilities:
                          '0': 0
                          '1': 0
                          '2': 1
                        confidence: 1
                      sentiment:
                        type: choice
                        choice: positive
                        probabilities:
                          negative: 0
                          neutral: 0
                          positive: 1
                        confidence: 1
                    usage:
                      input_tokens_details:
                        cached_tokens: 0
                        cache_write_tokens: 0
                      input_tokens: 408
                      output_tokens: 0
                      input_cost: 0.0000408
                      output_cost: 0
                      total_cost: 0.0000408
              schema:
                additionalProperties: false
                properties:
                  answers:
                    additionalProperties:
                      $ref: '#/components/schemas/ClassifyAnswer'
                    description: >-
                      Answers keyed by the question identifiers from the
                      request.
                    type: object
                  model:
                    description: >-
                      The requested ID of the model that answered. This can be a
                      fallback model.
                    type: string
                  telemetry:
                    $ref: '#/components/schemas/ResponseTelemetry'
                    description: OpenTelemetry trace and span identifiers for this request.
                  usage:
                    $ref: '#/components/schemas/ClassifyUsage'
                    description: The usage information for the request.
                required:
                  - model
                  - answers
                  - usage
                type: object
          description: Returns one answer per question.
        '400':
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                properties:
                  error:
                    $ref: '#/components/schemas/APIError'
                required:
                  - error
          description: >-
            Malformed JSON, missing or unsupported model, or invalid retry,
            timeout, or fallback fields.
        '401':
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                properties:
                  error:
                    $ref: '#/components/schemas/APIError'
                required:
                  - error
          description: Missing, invalid, expired or revoked API key.
        '403':
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                properties:
                  error:
                    $ref: '#/components/schemas/APIError'
                required:
                  - error
          description: >-
            The API key lacks classify permission, or the workspace or project
            cannot access the model.
        '408':
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                properties:
                  error:
                    $ref: '#/components/schemas/APIError'
                required:
                  - error
          description: >-
            The final model call exceeded its timeout after available retries
            and fallbacks were exhausted.
        '422':
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                properties:
                  error:
                    $ref: '#/components/schemas/APIError'
                required:
                  - error
          description: The state or a question violates the classification contract.
        '429':
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                properties:
                  error:
                    $ref: '#/components/schemas/APIError'
                required:
                  - error
          description: A plan rate limit, budget or provider rate limit was exceeded.
        '500':
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                properties:
                  error:
                    $ref: '#/components/schemas/APIError'
                required:
                  - error
          description: An internal model-resolution error occurred.
        '502':
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                properties:
                  error:
                    $ref: '#/components/schemas/APIError'
                required:
                  - error
          description: >-
            The upstream provider failed or returned an invalid classification
            response.
      security:
        - ApiKey: []
      x-code-samples:
        - label: Python
          lang: python
          source: |-
            result = client.router.decisions.create(
                model="typesafe/jev-latest",
                state="The parcel arrived two days late and the box was crushed.",
                questions={
                    "is_complaint": {"type": "noul", "instructions": "Is the customer complaining?"},
                    "topic": {
                        "type": "choice",
                        "instructions": "What is the message mainly about?",
                        "criteria": {"delivery": "Shipping or delivery issues", "product": "Product quality", "other": None},
                    },
                    "severity": {"type": "score", "instructions": "How severe is the issue?", "criteria": ["Minor", "Moderate", "Severe"]},
                },
            )
        - label: 'cURL: OpenAI text'
          lang: bash
          source: |-
            curl https://router.toqan.ai/eu/v3/router/decisions \
              -H "Authorization: Bearer ${TOQAN_API_KEY}" \
              -H "Content-Type: application/json" \
              --data-binary @- <<'JSON'
            {
              "model": "openai/gpt-6-luna",
              "questions": {
                "positive": {
                  "criteria": {
                    "false": "The customer is unhappy.",
                    "true": "The customer is happy."
                  },
                  "instructions": "Is the sentiment positive?",
                  "type": "noul"
                },
                "rating": {
                  "criteria": [
                    "Negative",
                    "Neutral",
                    "Positive"
                  ],
                  "instructions": "Rate sentiment.",
                  "type": "score"
                },
                "sentiment": {
                  "criteria": {
                    "negative": "Negative sentiment",
                    "neutral": null,
                    "positive": "Positive sentiment"
                  },
                  "instructions": "Classify sentiment.",
                  "type": "choice"
                }
              },
              "state": "The customer says: I love this product. It is wonderful!"
            }
            JSON
        - label: 'cURL: OpenAI inline image'
          lang: bash
          source: |-
            curl https://router.toqan.ai/eu/v3/router/decisions \
              -H "Authorization: Bearer ${TOQAN_API_KEY}" \
              -H "Content-Type: application/json" \
              --data-binary @- <<'JSON'
            {
              "model": "openai/gpt-6-luna",
              "questions": {
                "contains_text": {
                  "instructions": "Does the image contain text?",
                  "type": "noul"
                }
              },
              "state": [
                {
                  "content": [
                    {
                      "text": "Evaluate this image.",
                      "type": "input_text"
                    },
                    {
                      "image_url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAACLSURBVHgBdY8NDYAgEIXBBEQgAhG0gRGMYBNtoA2M4EygDYygDfCxvdMbk7d9A453f8ZQMcYAWuBVzIHujeGyxE8nYz7dJWYl01p749zxDKABEzhYfDNaMPZSAUymJLZLuvSsSVUhx4G7VM2xpSzQ5YYhLUHDCGoad47ixXjxY84qi1a9QPgZpdYLPVkbtsfywz3jAAAAAElFTkSuQmCC",
                      "type": "input_image"
                    }
                  ],
                  "role": "user"
                }
              ]
            }
            JSON
        - label: 'cURL: Fallbacks, retries and identity'
          lang: bash
          source: |-
            curl https://router.toqan.ai/eu/v3/router/decisions \
              -H "Authorization: Bearer ${TOQAN_API_KEY}" \
              -H "Content-Type: application/json" \
              --data-binary @- <<'JSON'
            {
              "fallbacks": [
                {
                  "model": "openai/gpt-5.6-luna"
                }
              ],
              "identity": {
                "id": "customer-demo",
                "display_name": "Sample customer"
              },
              "model": "openai/gpt-6-luna",
              "questions": {
                "positive": {
                  "criteria": {
                    "false": "The customer is unhappy.",
                    "true": "The customer is happy."
                  },
                  "instructions": "Is the sentiment positive?",
                  "type": "noul"
                },
                "rating": {
                  "criteria": [
                    "Negative",
                    "Neutral",
                    "Positive"
                  ],
                  "instructions": "Rate sentiment.",
                  "type": "score"
                },
                "sentiment": {
                  "criteria": {
                    "negative": "Negative sentiment",
                    "neutral": null,
                    "positive": "Positive sentiment"
                  },
                  "instructions": "Classify sentiment.",
                  "type": "choice"
                }
              },
              "retry": {
                "count": 2,
                "on_codes": [
                  429,
                  502,
                  503,
                  504
                ]
              },
              "state": "The customer says: I love this product. It is wonderful!",
              "timeout": {
                "call_timeout": 2000
              }
            }
            JSON
components:
  schemas:
    ClassifyAsset:
      additionalProperties: false
      properties:
        data_base64:
          description: >-
            Standard base64 with padding, without whitespace or a data: prefix.
            PNG or JPEG still images, 256 to 1568 px per side, at most 16 MiB
            each.
          type: string
        format:
          description: The image format.
          enum:
            - png
            - jpg
            - jpeg
          type: string
        type:
          description: The asset type. Only image is supported.
          enum:
            - image
          type: string
      required:
        - data_base64
        - format
      type: object
    ClassifyCacheConfig:
      additionalProperties: false
      properties:
        ttl:
          description: >-
            Time to live for the cached response in seconds, up to 259200 (3
            days). Defaults to 3600.
          format: int64
          maximum: 259200
          minimum: 1
          type: integer
        type:
          description: Cache type. Only exact_match is supported.
          enum:
            - exact_match
          type: string
      required:
        - type
      type: object
    FallbackConfig:
      additionalProperties: false
      properties:
        model:
          type: string
      required:
        - model
      type: object
    ResponseIdentity:
      additionalProperties: false
      properties:
        display_name:
          type: string
        email:
          type: string
        id:
          type: string
        metadata:
          items:
            type: object
            additionalProperties: {}
          type:
            - array
            - 'null'
        tags:
          items:
            type: string
          type:
            - array
            - 'null'
      required:
        - id
      type: object
    ClassifyPromptCacheOptions:
      additionalProperties: false
      properties:
        mode:
          description: >-
            Implicit uses the shared input boundary by default; explicit uses
            only marked input boundaries.
          enum:
            - implicit
            - explicit
          type: string
        ttl:
          description: >-
            Minimum cache lifetime. Only 30m is supported by native OpenAI
            Decisions.
          enum:
            - 30m
          type: string
      type: object
    ClassifyRetryConfig:
      additionalProperties: false
      properties:
        count:
          description: >-
            Number of retries per model after the initial attempt (0-5). Set 0
            to disable retries. When retry is omitted, the gateway retries
            twice.
          format: int64
          maximum: 5
          minimum: 0
          type: integer
        on_codes:
          description: >-
            HTTP status codes that trigger retries, between 100 and 599.
            Defaults to [408, 429, 500, 502, 503, 504, 529]. Retry-After is
            honored; otherwise the gateway backs off exponentially.
          items:
            format: int64
            maximum: 599
            minimum: 100
            type: integer
          type: array
      required:
        - count
      type: object
    ClassifyTimeoutConfig:
      additionalProperties: false
      properties:
        call_timeout:
          description: >-
            Timeout in milliseconds for each model call. Set 2000 for two
            seconds. When retry is configured, timeout errors (408) are
            automatically retried.
          format: int64
          minimum: 1
          type: integer
      required:
        - call_timeout
      type: object
    ClassifyAnswer:
      description: >-
        One answer to a classification question. The type selects the answer
        fields. A refusal contains only type.
      discriminator:
        mapping:
          box: '#/components/schemas/ClassifyBoxAnswer'
          choice: '#/components/schemas/ClassifyChoiceAnswer'
          noul: '#/components/schemas/ClassifyNoulAnswer'
          refusal: '#/components/schemas/ClassifyRefusalAnswer'
          score: '#/components/schemas/ClassifyScoreAnswer'
        propertyName: type
      oneOf:
        - $ref: '#/components/schemas/ClassifyNoulAnswer'
        - $ref: '#/components/schemas/ClassifyChoiceAnswer'
        - $ref: '#/components/schemas/ClassifyScoreAnswer'
        - $ref: '#/components/schemas/ClassifyBoxAnswer'
        - $ref: '#/components/schemas/ClassifyRefusalAnswer'
    ResponseTelemetry:
      additionalProperties: false
      properties:
        span_id:
          type: string
        trace_id:
          type: string
      required:
        - trace_id
        - span_id
      type: object
    ClassifyUsage:
      additionalProperties: false
      properties:
        input_cost:
          description: >-
            Cost (USD) of input tokens. Present when billing was computed for
            this request.
          format: double
          type: number
        input_tokens:
          description: The number of input tokens processed.
          format: int64
          type: integer
        input_tokens_details:
          $ref: '#/components/schemas/ClassifyInputTokensDetails'
          description: >-
            Provider-reported cache token usage. OpenAI Decisions charges cache
            reads and writes at the model cache rates; these tokens are included
            in input_tokens.
        output_cost:
          description: >-
            Cost (USD) of output tokens. 0 for native classify providers,
            including OpenAI Decisions. Present when billing was computed for
            this request.
          format: double
          type: number
        output_tokens:
          description: >-
            The number of output tokens generated. Free for native classify
            providers, billed at the model rate for emulated chat models.
          format: int64
          type: integer
        total_cost:
          description: >-
            Total cost (USD) of the request. Present when billing was computed
            for this request.
          format: double
          type: number
      required:
        - input_tokens
        - output_tokens
      type: object
    APIError:
      additionalProperties: false
      properties:
        code:
          type:
            - string
            - 'null'
        failures: {}
        message:
          type: string
        param:
          type:
            - string
            - 'null'
        type:
          type: string
      required:
        - message
        - type
        - param
        - code
      type: object
    ClassifyBoxAnswer:
      additionalProperties: false
      properties:
        box:
          $ref: '#/components/schemas/ClassifyBox'
          description: The bounding box of the target. Present for box answers.
        confidence:
          description: >-
            How sure the model is of the answer it selected: on emulated chat
            models the largest value in probabilities, so it adds nothing the
            distribution does not; native providers return their own confidence
            value, which can sit below the largest probability. Present for
            choice, score and box answers.
          format: double
          type: number
        type:
          enum:
            - box
          type: string
      required:
        - type
        - box
      title: ClassifyBoxAnswer
      type: object
    ClassifyChoiceAnswer:
      additionalProperties: false
      properties:
        choice:
          description: The selected option. Present for choice answers.
          type: string
        confidence:
          description: >-
            How sure the model is of the answer it selected: on emulated chat
            models the largest value in probabilities, so it adds nothing the
            distribution does not; native providers return their own confidence
            value, which can sit below the largest probability. Present for
            choice, score and box answers.
          format: double
          type: number
        probabilities:
          additionalProperties:
            type: number
            format: double
          description: >-
            Probability distribution over the options or levels. Present for
            choice and score answers.
          type: object
        type:
          enum:
            - choice
          type: string
      required:
        - type
        - choice
      title: ClassifyChoiceAnswer
      type: object
    ClassifyNoulAnswer:
      additionalProperties: false
      properties:
        noul:
          description: >-
            Probability between 0 and 1 that the statement holds. Present for
            noul answers.
          format: double
          type: number
        type:
          enum:
            - noul
          type: string
      required:
        - type
        - noul
      title: ClassifyNoulAnswer
      type: object
    ClassifyRefusalAnswer:
      additionalProperties: false
      properties:
        type:
          enum:
            - refusal
          type: string
      required:
        - type
      title: ClassifyRefusalAnswer
      type: object
    ClassifyScoreAnswer:
      additionalProperties: false
      properties:
        confidence:
          description: >-
            How sure the model is of the answer it selected: on emulated chat
            models the largest value in probabilities, so it adds nothing the
            distribution does not; native providers return their own confidence
            value, which can sit below the largest probability. Present for
            choice, score and box answers.
          format: double
          type: number
        legend:
          additionalProperties:
            type: string
          description: Level index to level description. Present for score answers.
          type: object
        probabilities:
          additionalProperties:
            type: number
            format: double
          description: >-
            Probability distribution over the options or levels. Present for
            choice and score answers.
          type: object
        score:
          description: >-
            Position on the scale, not an index: on emulated chat models and
            OpenAI Decisions the weighted index, each level index multiplied by
            that level probability and summed, so the value is usually
            fractional; typesafe/jev-latest returns its own score. Present for
            score answers.
          format: double
          type: number
        type:
          enum:
            - score
          type: string
      required:
        - type
        - score
      title: ClassifyScoreAnswer
      type: object
    ClassifyInputTokensDetails:
      additionalProperties: false
      properties:
        cache_write_tokens:
          description: Input tokens written to cache.
          format: int64
          type: integer
        cached_tokens:
          description: Input tokens read from cache.
          format: int64
          type: integer
      required:
        - cached_tokens
        - cache_write_tokens
      type: object
    ClassifyBox:
      additionalProperties: false
      properties:
        bottom:
          description: >-
            Distance of the bottom edge from the top of the image, as a fraction
            of the image height.
          format: double
          maximum: 1
          minimum: 0
          type: number
        left:
          description: >-
            Distance of the left edge from the left of the image, as a fraction
            of the image width.
          format: double
          maximum: 1
          minimum: 0
          type: number
        right:
          description: >-
            Distance of the right edge from the left of the image, as a fraction
            of the image width.
          format: double
          maximum: 1
          minimum: 0
          type: number
        top:
          description: >-
            Distance of the top edge from the top of the image, as a fraction of
            the image height.
          format: double
          maximum: 1
          minimum: 0
          type: number
      required:
        - top
        - bottom
        - left
        - right
      type: object
  securitySchemes:
    ApiKey:
      type: http
      scheme: bearer
      bearerFormat: JWT

````

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