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

# Decision

> Runs a decision model synchronously: the model answers typed questions (noul, choice, score...) about a state with probabilities. Billed like a chat completion, from the input and output tokens of the routed model. Provider failures preserve an upstream 4xx status, except 401 and 402 which return 503, and use the provider_error code; upstream 5xx failures return 503.



## OpenAPI

````yaml /hub/openapi/hub.json post /api/v1/hub/decisions
openapi: 3.0.1
info:
  title: Fanify Hub API
  description: Generate media and text with Fanify credits. All prices use EUR.
  version: v1
servers:
  - url: https://fanifyai.com
security: []
paths:
  /api/v1/hub/decisions:
    post:
      tags:
        - Decisions
      summary: Decision
      description: >-
        Runs a decision model synchronously: the model answers typed questions
        (noul, choice, score...) about a state with probabilities. Billed like a
        chat completion, from the input and output tokens of the routed model.
        Provider failures preserve an upstream 4xx status, except 401 and 402
        which return 503, and use the provider_error code; upstream 5xx failures
        return 503.
      parameters:
        - name: Idempotency-Key
          in: header
          description: >-
            Optional idempotency key, from 1 to 255 characters. Use one key per
            request.
          schema:
            type: string
      requestBody:
        description: >-
          Decision request in the OpenRouter Decisions format (state + typed
          questions: noul, choice, score...).Additional top-level fields are
          forwarded.
        content:
          application/json:
            schema:
              required:
                - model
                - state
                - questions
              type: object
              properties:
                model:
                  type: string
                state:
                  description: >-
                    String, object or array of content parts; images as
                    image_url parts with a data: URL.
                questions:
                  type: object
                  description: >-
                    Non-empty object: question key -> {type, instructions,
                    criteria?}.
            example:
              model: decision-model
              state: 'Fan: Hi, I''m Paul. Do you sell photos?'
              questions:
                intent:
                  type: choice
                  instructions: What does the fan want?
                  criteria:
                    buy: Wants to buy content
                    other: null
        required: true
      responses:
        '200':
          description: Decision answers with probabilities.
          headers:
            X-Fanify-Generation-Id:
              description: Hub generation identifier.
              schema:
                type: string
            X-Fanify-Billed-Cost:
              description: Billed cost in EUR, using invariant decimal notation.
              schema:
                type: string
          content:
            application/json:
              schema:
                type: object
              example:
                id: 0192f3a4-8c1e-7b2a-9f10-2b6d4e0c9a11
                model: decision-model
                answers:
                  first_name:
                    type: noul
                    noul: 0.93
                    confidence: 0.93
                  intent:
                    type: choice
                    choice: buy
                    confidence: 0.81
                    probabilities:
                      buy: 0.81
                      other: 0.19
                usage:
                  input_tokens: 412
                  output_tokens: 0
                  cost: 0.000005
        '400':
          description: OpenAI-compatible error.
          content:
            application/json:
              schema:
                required:
                  - error
                type: object
                properties:
                  error:
                    required:
                      - message
                      - code
                      - type
                    type: object
                    properties:
                      message:
                        type: string
                      code:
                        enum:
                          - invalid_input
                          - provider_error
                        type: string
                      type:
                        type: string
                      metadata:
                        required:
                          - provider_name
                        type: object
                        properties:
                          provider_name:
                            enum:
                              - FanifyHub
                            type: string
              example:
                error:
                  message: The request input is invalid.
                  code: invalid_input
                  type: invalid_request_error
        '401':
          description: Unauthorized
          content:
            application/problem+json:
              schema:
                required:
                  - type
                  - title
                  - status
                  - code
                type: object
                properties:
                  type:
                    type: string
                    format: uri
                  title:
                    type: string
                  status:
                    type: integer
                    format: int32
                  detail:
                    type: string
                    nullable: true
                  instance:
                    type: string
                  code:
                    enum:
                      - unauthorized
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
                  unrepresentable:
                    type: array
                    items:
                      type: string
                  missing:
                    type: array
                    items:
                      required:
                        - sha256
                      type: object
                      properties:
                        sha256:
                          type: string
                        kind:
                          type: string
                          nullable: true
              example:
                type: https://fanifyai.com/docs/hub/errors#unauthorized
                title: Unauthorized
                status: 401
                code: unauthorized
        '402':
          description: OpenAI-compatible error.
          content:
            application/json:
              schema:
                required:
                  - error
                type: object
                properties:
                  error:
                    required:
                      - message
                      - code
                      - type
                    type: object
                    properties:
                      message:
                        type: string
                      code:
                        enum:
                          - insufficient_credits
                        type: string
                      type:
                        type: string
                      metadata:
                        required:
                          - provider_name
                        type: object
                        properties:
                          provider_name:
                            enum:
                              - FanifyHub
                            type: string
              example:
                error:
                  message: Your available balance does not cover this generation.
                  code: insufficient_credits
                  type: invalid_request_error
        '404':
          description: OpenAI-compatible error.
          content:
            application/json:
              schema:
                required:
                  - error
                type: object
                properties:
                  error:
                    required:
                      - message
                      - code
                      - type
                    type: object
                    properties:
                      message:
                        type: string
                      code:
                        enum:
                          - model_not_found
                        type: string
                      type:
                        type: string
                      metadata:
                        required:
                          - provider_name
                        type: object
                        properties:
                          provider_name:
                            enum:
                              - FanifyHub
                            type: string
              example:
                error:
                  message: The requested model was not found.
                  code: model_not_found
                  type: invalid_request_error
        '410':
          description: OpenAI-compatible error.
          content:
            application/json:
              schema:
                required:
                  - error
                type: object
                properties:
                  error:
                    required:
                      - message
                      - code
                      - type
                    type: object
                    properties:
                      message:
                        type: string
                      code:
                        enum:
                          - file_expired
                        type: string
                      type:
                        type: string
                      metadata:
                        required:
                          - provider_name
                        type: object
                        properties:
                          provider_name:
                            enum:
                              - FanifyHub
                            type: string
              example:
                error:
                  message: The requested file has expired or is unavailable.
                  code: file_expired
                  type: invalid_request_error
        '413':
          description: OpenAI-compatible error.
          content:
            application/json:
              schema:
                required:
                  - error
                type: object
                properties:
                  error:
                    required:
                      - message
                      - code
                      - type
                    type: object
                    properties:
                      message:
                        type: string
                      code:
                        enum:
                          - payload_too_large
                        type: string
                      type:
                        type: string
                      metadata:
                        required:
                          - provider_name
                        type: object
                        properties:
                          provider_name:
                            enum:
                              - FanifyHub
                            type: string
              example:
                error:
                  message: The uploaded file exceeds the allowed size.
                  code: payload_too_large
                  type: invalid_request_error
        '422':
          description: OpenAI-compatible error.
          content:
            application/json:
              schema:
                required:
                  - error
                type: object
                properties:
                  error:
                    required:
                      - message
                      - code
                      - type
                    type: object
                    properties:
                      message:
                        type: string
                      code:
                        enum:
                          - idempotency_conflict
                          - no_route_available
                        type: string
                      type:
                        type: string
                      metadata:
                        required:
                          - provider_name
                        type: object
                        properties:
                          provider_name:
                            enum:
                              - FanifyHub
                            type: string
              example:
                error:
                  message: >-
                    This idempotency key was already used with a different
                    request.
                  code: idempotency_conflict
                  type: invalid_request_error
        '429':
          description: OpenAI-compatible error.
          headers:
            Retry-After:
              description: >-
                Optional. Sent (2 seconds) with capacity_exhausted, when the
                admission wait timed out; absent for the per-key rate limit
                (rate_limited).
              schema:
                type: string
          content:
            application/json:
              schema:
                required:
                  - error
                type: object
                properties:
                  error:
                    required:
                      - message
                      - code
                      - type
                    type: object
                    properties:
                      message:
                        type: string
                      code:
                        enum:
                          - rate_limited
                          - capacity_exhausted
                        type: string
                      type:
                        type: string
                      metadata:
                        required:
                          - provider_name
                        type: object
                        properties:
                          provider_name:
                            enum:
                              - FanifyHub
                            type: string
              example:
                error:
                  message: Rate limit reached, retry later.
                  code: rate_limited
                  type: invalid_request_error
        '503':
          description: OpenAI-compatible error.
          headers:
            Retry-After:
              description: Always 5 seconds for an in-progress replay.
              schema:
                type: string
          content:
            application/json:
              schema:
                required:
                  - error
                type: object
                properties:
                  error:
                    required:
                      - message
                      - code
                      - type
                    type: object
                    properties:
                      message:
                        type: string
                      code:
                        enum:
                          - generation_in_progress
                          - provider_error
                          - hub_paused
                        type: string
                      type:
                        type: string
                      metadata:
                        required:
                          - provider_name
                        type: object
                        properties:
                          provider_name:
                            enum:
                              - FanifyHub
                            type: string
              example:
                error:
                  message: A generation with this idempotency key is still in progress.
                  code: generation_in_progress
                  type: invalid_request_error
      security:
        - Bearer: []
components:
  securitySchemes:
    Bearer:
      type: http
      description: Fanify API key.
      scheme: bearer
      bearerFormat: fanify_sk_...

````

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