# Response format

Source: https://docs.temprl.org/api/response

> The JSON returned by POST /v1/ask - answers per question type, usage and cost, and the response headers.

```json
{
  "id": "evt_8sKq2...",
  "model": "simo-1-pro",
  "answers": {
    "refund": {"type": "noul", "noul": 0.991},
    "team":   {"type": "choice", "choice": "billing",
               "probabilities": {"billing": 0.962, "shipping": 0.021, "tech": 0.017}, "confidence": 0.962},
    "mood":   {"type": "score", "score": 2.31,
               "legend": {"0": "calm", "1": "annoyed", "2": "angry", "3": "furious"},
               "probabilities": {"0": 0.02, "1": 0.11, "2": 0.41, "3": 0.46}, "confidence": 0.46},
    "amount": {"type": "fill", "value": "89", "parsed": 89.0, "valid": true, "confidence": 0.99}
  },
  "usage": {"input_tokens": 212, "output_tokens": 0, "cost": 0.00000636}
}
```

| Field | Description |
|---|---|
| `id` | The request id, also sent as `x-request-id`. Quote it to support |
| `model` | The model that answered |
| `answers` | One answer per question id, plus one per `derive` name |
| `usage.input_tokens` | Input tokens read (what you pay for) |
| `usage.output_tokens` | Output tokens written (free) |
| `usage.cost` | Cost of this request in US dollars |

Other fields (more `usage` detail, and service metadata under `simo`) may appear. Ignore what you don't use.

## Answers by type

| `type` | Fields |
|---|---|
| `noul` | `noul`: P(true), in [0, 1] |
| `choice` | `choice`: the most likely option. `probabilities`: `{option: p}`, summing to 1. `confidence`. `args`: `{name: answer}` for the chosen option, when the question had `args` |
| `score` | `score`: the expected level, 0-based. `legend`: `{"0": level, ...}`. `probabilities`: `{"0": p, ...}`, one per level. `confidence`: the largest of them |
| `fill` | `value`: the text. `parsed`: the typed value (int, number or list) when `kind` says so. `valid`. `confidence`. `check` with `self_check` |
| `extract` | `value` (or `values` with `many`). `valid`. `confidence`. `check` with `self_check` |
| extract, `kind: "coordinates"` | `coordinates`: `[x1, y1, x2, y2]` or `null`. `center`: `[x, y]` or `null`. `image_size`: `[width, height]`. `valid`. `confidence` |

Decision probabilities (`noul`, `probabilities`) are calibrated. `confidence` on reads is not; `check` is.

Coordinates are in the pixels of the image **as sent**. If you resized or padded an image before sending it, map the answer back yourself (the Python SDK does this for you).

## Headers

| Header | Example | Description |
|---|---|---|
| `x-request-id` | `evt_8sKq2...` | The request id |
| `x-simo-cost-usd` | `0.000006360` | What this request cost |
| `x-simo-balance-usd` | `24.999993640` | Your balance after it |
| `x-simo-latency-ms` | `412` | Time spent in the API |

These headers are exposed to browsers through CORS, though keys belong on your server.
