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

# Create Decision

> Ask typed questions about a piece of content and get a calibrated answer for each one.

<RequestExample>
  ```bash cURL theme={"dark"}
  curl https://router.requesty.ai/v1/decisions \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer YOUR_REQUESTY_API_KEY" \
    -d '{
      "model": "openai/gpt-6-luna",
      "state": "The dragon heist in this fantasy novel had me hooked, but the ending dragged a little.",
      "questions": {
        "positive": {
          "type": "noul",
          "instructions": "The review is positive."
        },
        "genre": {
          "type": "choice",
          "instructions": "Which genre is the book?",
          "criteria": {
            "fantasy": "Magic, myth or invented worlds",
            "mystery": "A crime or puzzle to solve",
            "romance": "A love story"
          }
        },
        "rating": {
          "type": "score",
          "instructions": "How much did the reviewer enjoy the book?",
          "criteria": ["Hated it", "Disliked it", "Neutral", "Liked it", "Loved it"]
        }
      }
    }'
  ```

  ```python Python theme={"dark"}
  import httpx

  response = httpx.post(
      "https://router.requesty.ai/v1/decisions",
      headers={"Authorization": "Bearer YOUR_REQUESTY_API_KEY"},
      json={
          "model": "openai/gpt-6-luna",
          "state": "The dragon heist in this fantasy novel had me hooked, but the ending dragged a little.",
          "questions": {
              "positive": {"type": "noul", "instructions": "The review is positive."},
          },
      },
  )

  answer = response.json()["answers"]["positive"]
  if answer["type"] == "refusal":
      print("The model declined to answer")
  else:
      print(answer["noul"])
  ```

  ```typescript TypeScript theme={"dark"}
  const response = await fetch("https://router.requesty.ai/v1/decisions", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.REQUESTY_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      model: "openai/gpt-6-luna",
      state: "The dragon heist in this fantasy novel had me hooked, but the ending dragged a little.",
      questions: {
        positive: { type: "noul", instructions: "The review is positive." },
      },
    }),
  });

  const { answers } = await response.json();
  const answer = answers.positive;
  console.log(answer.type === "refusal" ? "The model declined to answer" : answer.noul);
  ```
</RequestExample>

<ResponseExample>
  ```json Response 200 theme={"dark"}
  {
    "answers": {
      "genre": {
        "type": "choice",
        "choice": "fantasy",
        "confidence": 1,
        "probabilities": {
          "fantasy": 1,
          "mystery": 0,
          "romance": 0
        }
      },
      "positive": {
        "type": "noul",
        "noul": 0.73
      },
      "rating": {
        "type": "score",
        "score": 3.1,
        "confidence": 0.87,
        "probabilities": [
          { "value": 0, "probability": 0.01 },
          { "value": 1, "probability": 0 },
          { "value": 2, "probability": 0 },
          { "value": 3, "probability": 0.86 },
          { "value": 4, "probability": 0.13 }
        ]
      }
    },
    "id": "rqsty-dcsn-15e2efde-f7c6-49cb-92ae-c763b1b16193",
    "model": "gpt-6-luna",
    "provider": "openai",
    "usage": {
      "input_tokens": 424,
      "output_tokens": 0
    }
  }
  ```

  ```json Refusal theme={"dark"}
  {
    "answers": {
      "positive": {
        "type": "refusal"
      }
    },
    "id": "rqsty-dcsn-75924058-d3b3-471a-b19c-4e003550bcc7",
    "model": "gpt-6-luna",
    "provider": "openai",
    "usage": {
      "input_tokens": 5,
      "output_tokens": 0
    }
  }
  ```
</ResponseExample>

Ask typed questions about a piece of content and get a calibrated answer for each one. List the available models with [`/v1/models/decision`](/api-reference/endpoint/models-decision-list). See [Decisions](/features/decisions) for the question types.

Every answer has a `type`. A model can decline a question and return `{"type": "refusal"}` for it, so check `type` before reading the value. See OpenAI's [Decisions guide](https://developers.openai.com/api/docs/guides/decisions).

Responses are not streamed.

## Images

`cloudflare/clef` and `openai/gpt-6-luna` also look at images. Send them in `images` as base64 data URLs. Remote image URLs are rejected.

```bash theme={"dark"}
curl https://router.requesty.ai/v1/decisions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_REQUESTY_API_KEY" \
  -d '{
    "model": "openai/gpt-6-luna",
    "state": "Listing title: Red leather armchair",
    "images": ["data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD..."],
    "questions": {
      "matches_title": {
        "type": "noul",
        "instructions": "The photo shows the item in the title."
      },
      "color": {
        "type": "choice",
        "instructions": "What is the main colour in the photo?",
        "criteria": {
          "red": "Red",
          "green": "Green",
          "blue": "Blue"
        }
      }
    }
  }'
```

```json theme={"dark"}
{
  "answers": {
    "color": {
      "type": "choice",
      "choice": "red",
      "confidence": 0.99,
      "probabilities": {
        "blue": 0,
        "green": 0.01,
        "red": 0.99
      }
    },
    "matches_title": {
      "type": "noul",
      "noul": 0.52
    }
  },
  "id": "rqsty-dcsn-b57050ea-7298-4d59-a0b0-ffc87db60fe8",
  "model": "gpt-6-luna",
  "provider": "openai",
  "usage": {
    "input_tokens": 287,
    "output_tokens": 0
  }
}
```


## OpenAPI

````yaml POST /v1/decisions
openapi: 3.0.3
info:
  title: Requesty Inference API
  description: >-
    Requesty Inference API for AI model routing. OpenAI-compatible endpoints for
    chat completions, embeddings, images, audio, and more.
  version: 1.0.0
servers:
  - url: https://router.requesty.ai
    description: Inference router endpoint
security:
  - BearerAuth: []
paths:
  /v1/decisions:
    servers:
      - url: https://router.requesty.ai
        description: Inference router endpoint
    post:
      summary: Create decision
      description: >-
        Ask typed questions about a piece of content and get a calibrated answer
        for each one.
      operationId: createDecision
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DecisionRequest'
            example:
              model: openai/gpt-6-luna
              state: >-
                The dragon heist in this fantasy novel had me hooked, but the
                ending dragged a little.
              questions:
                positive:
                  type: noul
                  instructions: The review is positive.
                genre:
                  type: choice
                  instructions: Which genre is the book?
                  criteria:
                    fantasy: Magic, myth or invented worlds
                    mystery: A crime or puzzle to solve
                    romance: A love story
                rating:
                  type: score
                  instructions: How much did the reviewer enjoy the book?
                  criteria:
                    - Hated it
                    - Disliked it
                    - Neutral
                    - Liked it
                    - Loved it
      responses:
        '200':
          description: Decision response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DecisionResponse'
              example:
                answers:
                  genre:
                    type: choice
                    choice: fantasy
                    confidence: 1
                    probabilities:
                      fantasy: 1
                      mystery: 0
                      romance: 0
                  positive:
                    type: noul
                    noul: 0.73
                  rating:
                    type: score
                    score: 3.1
                    confidence: 0.87
                    probabilities:
                      - value: 0
                        probability: 0.01
                      - value: 1
                        probability: 0
                      - value: 2
                        probability: 0
                      - value: 3
                        probability: 0.86
                      - value: 4
                        probability: 0.13
                id: rqsty-dcsn-15e2efde-f7c6-49cb-92ae-c763b1b16193
                model: gpt-6-luna
                provider: openai
                usage:
                  input_tokens: 424
                  output_tokens: 0
        '400':
          description: Bad request - malformed payload or invalid parameters.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized - missing or empty Authorization header.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '402':
          description: Payment required - organization balance exhausted.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden - invalid token or model not in access list.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Not found - provider/model not supported.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '413':
          description: Payload too large - the state exceeds the model's context window.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate limit exceeded. Retry after the Retry-After header value.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '502':
          description: Bad gateway - upstream provider returned an invalid response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    DecisionRequest:
      type: object
      required:
        - model
        - state
        - questions
      properties:
        model:
          type: string
          description: >-
            A decision model ID from
            [`/v1/models/decision`](/api-reference/endpoint/models-decision-list).
          example: openai/gpt-6-luna
        state:
          description: 'The content to evaluate: a string, an object or an array.'
        questions:
          type: object
          description: Map of question ID to question. Each ID gets one entry in `answers`.
          additionalProperties:
            $ref: '#/components/schemas/DecisionQuestion'
        images:
          type: array
          items:
            type: string
          description: >-
            Base64 image data URLs (`data:image/...;base64,...`). Only for
            models that accept images (`cloudflare/clef`, `openai/gpt-6-luna`).
            Remote URLs are rejected.
    DecisionResponse:
      type: object
      required:
        - answers
        - model
        - usage
      properties:
        answers:
          type: object
          description: One answer per question ID.
          additionalProperties:
            $ref: '#/components/schemas/DecisionAnswer'
        id:
          type: string
          example: rqsty-dcsn-15e2efde-f7c6-49cb-92ae-c763b1b16193
        model:
          type: string
          description: The upstream model name.
          example: gpt-6-luna
        provider:
          type: string
          example: openai
        usage:
          $ref: '#/components/schemas/DecisionUsage'
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - origin
            - message
          properties:
            origin:
              type: string
              enum:
                - router
                - provider
              description: >-
                Whether the error originated from Requesty's router or an
                upstream provider.
            message:
              type: string
              description: Human-readable error description.
    DecisionQuestion:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - noul
            - choice
            - score
          description: >-
            `noul`: yes/no, answered with a probability. `choice`: pick one
            option from `criteria`. `score`: a position on the ordered scale in
            `criteria`.
        instructions:
          description: What to ask about the state. Usually a string.
          oneOf:
            - type: string
            - type: array
              items:
                type: string
        criteria:
          description: >-
            For `choice`: an object mapping each option to its description. For
            `score`: a list of labels from lowest to highest. Not used by
            `noul`.
          oneOf:
            - type: object
              additionalProperties:
                type: string
                nullable: true
            - type: array
              items:
                type: string
    DecisionAnswer:
      type: object
      required:
        - type
      description: >-
        Answer to one question. Check `type` first: a model can return `refusal`
        instead of answering.
      properties:
        type:
          type: string
          enum:
            - noul
            - choice
            - score
            - refusal
        noul:
          type: number
          description: '`noul` only. Probability between 0 and 1 that the statement is true.'
        choice:
          type: string
          description: '`choice` only. The most likely option.'
        score:
          type: number
          description: >-
            `score` only. Probability-weighted average of the zero-based label
            indices, so it can be fractional.
        confidence:
          type: number
          description: >-
            `choice` and `score` only. Confidence in the answer, between 0 and
            1.
        probabilities:
          description: >-
            `choice` and `score` only. Probability per option (`choice`) or per
            label index (`score`). Depending on the model, score probabilities
            are an object keyed by index or a list of `{value, probability}`.
          oneOf:
            - type: object
              additionalProperties:
                type: number
            - type: array
              items:
                type: object
                properties:
                  value:
                    type: integer
                  probability:
                    type: number
        legend:
          type: object
          additionalProperties:
            type: string
          description: '`score` only, on some models. Maps each label index to its label.'
    DecisionUsage:
      type: object
      required:
        - input_tokens
        - output_tokens
      properties:
        input_tokens:
          type: integer
        output_tokens:
          type: integer
          description: Can be 0.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: API key for authentication

````

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