# Decisions

Typed answers to named questions about a piece of text, data, or an image

A Decisions model reads a `state` and answers each question you name with a fixed answer type. Use it for routing tickets, grading content, yes or no checks, and scoring. Decisions models are billed on input tokens only, and there is no output price. See [Services](https://silentapi.com/services) for current prices.

| Model | Input |
| --- | --- |
| `gemini-decision-1` | Text, images, audio, video, and files |
| `gpt-6-luna-decisions` | Text and images |
| `typesafe-jev-1.14` | Text and images |

## Request

Send a POST request to `/v1/decisions` with your API key in the `Authorization` header.

| Field | Type | Description |
| --- | --- | --- |
| `model` | string | A Decisions model. The default is `gemini-decision-1`. |
| `state` | string, object, or array | Required. The text, data, or media the questions are about. Images go in an array as `image_url` parts. |
| `questions` | object | From 1 to 50 questions, each under its own name of 1 to 64 letters, numbers, underscores, or hyphens. Required unless you send `options`. |
| `options` | array | Optional. From 2 to 255 options to rank, as text or as objects with `value` and `description`. See [Rank Options](#rank-options). |
| `instructions` | string | Optional. The question to ask about the options. The default is "Which option fits the state best?" |
| `question_name` | string | Optional. The name of the ranking question in `answers`. The default is `ranking`. |
| `top_k` | integer | Optional. How many ranked options to return, from 1 to 255. The default returns all of them. |
| `assets` | object | Optional. Named PNG or JPEG images that the state can refer to by name. |

## Question Types

Each question has a `type`, optional `instructions`, and `criteria` that describe the possible answers.

| Type | Criteria | Answer |
| --- | --- | --- |
| `noul` | An object with `true` and `false` descriptions | `noul`, the probability that the answer is true, plus `confidence` on most models |
| `choice` | An object of 2 to 255 named options | `choice`, plus `probabilities` for every option and `confidence` |
| `score` | A list of 2 to 10 levels from lowest to highest | `score` from 0 to the last level index, the probability weighted average of the levels, so it can fall between levels, plus `legend`, `probabilities` for every level, and `confidence` |
| `box` | None, describe the target in `instructions`. Only `typesafe-jev-1.14` answers box questions | `box` with `top`, `bottom`, `left`, and `right` as fractions of the image, plus `confidence` |

A model can decline one question. That answer comes back as `{ "type": "refusal" }`, which means the question was not answered, not that the answer is no. Not every model accepts every media part, and a request that the model cannot serve fails with status 400.

## Rank Options

Send `options` to rank a list. SilentAPI asks one choice question about them and returns the options ordered from most to least likely in `ranking`, with the top option in `choice`. You can send `options` together with other `questions` in the same request.

```
curl https://api.silentapi.com/v1/decisions \
  -H "Authorization: Bearer $SILENTAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "state": "Order 1042 arrived two weeks late and the box was crushed. The customer wants it fixed today.",
    "instructions": "What should support do first?",
    "options": [
      "apologize",
      { "value": "refund", "description": "Return the full payment." },
      { "value": "replace", "description": "Ship a new item by express." }
    ],
    "top_k": 2
  }'
```

```
{
  "object": "decision",
  "model": "gemini-decision-1",
  "answers": { "ranking": { "type": "choice", "choice": "replace", "probabilities": { "replace": 0.62, "refund": 0.31, "apologize": 0.07 }, "confidence": 0.62 } },
  "choice": "replace",
  "confidence": 0.62,
  "ranking": [
    { "rank": 1, "value": "replace", "probability": 0.62 },
    { "rank": 2, "value": "refund", "probability": 0.31 }
  ],
  "usage": { "input_tokens": 96 },
  "silentapi": {
    "cost": 0.0000121,
    "fallback": null,
    "model": "gemini-decision-1",
    "model_name": "Gemini Decision 1"
  },
  "cost": 0.0000121
}
```

## Example

```
curl https://api.silentapi.com/v1/decisions \
  -H "Authorization: Bearer $SILENTAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-decision-1",
    "state": { "tier": "business", "ticket": "Checkout shows a blank page after I click Pay." },
    "questions": {
      "is_bug": { "type": "noul", "instructions": "Is the customer reporting a defect?", "criteria": { "true": "Something is broken.", "false": "A question or a feature request." } },
      "team": { "type": "choice", "instructions": "Which team owns this ticket?", "criteria": { "payments": "Checkout and billing.", "frontend": "Layout and rendering.", "account": "Login and profile." } },
      "urgency": { "type": "score", "instructions": "How urgent is this ticket?", "criteria": ["Can wait", "This week", "Blocking sales now"] }
    }
  }'
```

The response holds one answer per question name, the input token count, and the cost in credits.

```
{
  "object": "decision",
  "model": "gemini-decision-1",
  "answers": {
    "is_bug": { "type": "noul", "noul": 0.94, "confidence": 0.94 },
    "team": {
      "type": "choice",
      "choice": "payments",
      "probabilities": { "payments": 0.88, "frontend": 0.1, "account": 0.02 },
      "confidence": 0.88
    },
    "urgency": {
      "type": "score",
      "score": 1.72,
      "legend": { "0": "Can wait", "1": "This week", "2": "Blocking sales now" },
      "probabilities": { "0": 0.04, "1": 0.2, "2": 0.76 },
      "confidence": 0.76
    }
  },
  "usage": { "input_tokens": 212 },
  "silentapi": {
    "cost": 0.0000265,
    "fallback": null,
    "model": "gemini-decision-1",
    "model_name": "Gemini Decision 1"
  },
  "cost": 0.0000265
}
```

When the chosen model is not available, the request moves to another Decisions model if you turned on Decisions [fallbacks](https://silentapi.com/docs/fallbacks).

Source: https://silentapi.com/docs/decisions
