# Create Decision

`POST https://api.vultrinference.com/v1/systemone`

Answer typed questions about a state with a decision ("System One") model, in TypeSafe's `/v1/systemone` shape, so clients written for TypeSafe work by changing their base URL and key.

A decision model reads the state once per question and generates no text: each answer is a probability distribution over the question's allowed answers.

**Question types:** `noul` (yes/no) answers `noul`, the probability of yes. `choice` picks one of 1 to 255 options and answers the most likely `choice`, every option's `probabilities` and a `confidence`. `score` rates on 1 to 10 ordered levels and answers `score`, the probability-weighted level (it can land between levels), with a `legend`, `probabilities` and `confidence`.

**Confidence** is 1 when the distribution is on one answer and 0 when it is spread evenly: (k * p_max - 1) / (k - 1) for k answers. `noul` answers carry none; read `noul` itself.

**Long inputs** over the model's maximum input length are rejected with 422, never truncated.

**Billing:** every question's prompt (the state, the question and its options) is billed as input tokens, so questions on a long state each bill the state. No output tokens are billed.

## Body (application/json)

- `model` (string, required): The [decision model](#operation/list-models) to use.
- `state` (string or object or array of any, required): What to decide about. A string, or structured data (an object or array), which the model reads as JSON.
- `questions` (object, required): Up to 64 questions, by id. Each answer comes back under its question's id.

## Responses

- `200`: OK (systemone-response-payload)
- `401`: The API key is missing, unknown or not active. Send it as Authorization: Bearer <key>. (error-payload)
- `422`: The request failed validation, the model is not a decision model, or an input is over the model's length (error-payload)
- `429`: Rate limit exceeded (error-payload)
- `502`: The model returned an unusable response (error-payload)
- `529`: The model is overloaded or unavailable; retry with backoff (error-payload)

## Example

```bash
curl https://api.vultrinference.com/v1/systemone \
  -H "Authorization: Bearer $VULTR_INFERENCE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "mica-v0.1-4b",
    "state": {
      "ticket": "Everything is down and we have a demo at noon."
    },
    "questions": {
      "urgent": {
        "type": "noul",
        "instructions": "Does the customer need a reply within the hour?"
      },
      "department": {
        "type": "choice",
        "instructions": "Which team should handle this?",
        "criteria": {
          "billing": "invoices, payments, refunds",
          "technical": "bugs, outages, errors"
        }
      },
      "frustration": {
        "type": "score",
        "instructions": "How frustrated is the customer?",
        "criteria": [
          "Calm",
          "Frustrated",
          "Very angry"
        ]
      }
    }
  }'
```

```python
import os
import requests

response = requests.post(
    "https://api.vultrinference.com/v1/systemone",
    headers={"Authorization": f"Bearer {os.environ['VULTR_INFERENCE_API_KEY']}"},
    json={
        "model": "mica-v0.1-4b",
        "state": {
            "ticket": "Everything is down and we have a demo at noon.",
        },
        "questions": {
            "urgent": {
                "type": "noul",
                "instructions": "Does the customer need a reply within the hour?",
            },
            "department": {
                "type": "choice",
                "instructions": "Which team should handle this?",
                "criteria": {
                    "billing": "invoices, payments, refunds",
                    "technical": "bugs, outages, errors",
                },
            },
            "frustration": {
                "type": "score",
                "instructions": "How frustrated is the customer?",
                "criteria": [
                    "Calm",
                    "Frustrated",
                    "Very angry",
                ],
            },
        },
    },
)
print(response.json())
```

```javascript
const response = await fetch("https://api.vultrinference.com/v1/systemone", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.VULTR_INFERENCE_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "model": "mica-v0.1-4b",
    "state": {
      "ticket": "Everything is down and we have a demo at noon."
    },
    "questions": {
      "urgent": {
        "type": "noul",
        "instructions": "Does the customer need a reply within the hour?"
      },
      "department": {
        "type": "choice",
        "instructions": "Which team should handle this?",
        "criteria": {
          "billing": "invoices, payments, refunds",
          "technical": "bugs, outages, errors"
        }
      },
      "frustration": {
        "type": "score",
        "instructions": "How frustrated is the customer?",
        "criteria": [
          "Calm",
          "Frustrated",
          "Very angry"
        ]
      }
    }
  }),
});
console.log(await response.json());
```
