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

# OpenAI Decisions API

> Sage in OpenAI's Decisions format.

If your code already calls OpenAI's `POST /v1/decisions`, change the base URL to `https://api.levanto.ai/v1` and use your Levanto key. Set `model` to `levanto-sage-2` or `sage-latest`. Each question is answered as [`/decide`](https://docs.levanto.ai/decision-model/quickstart) answers the same question.

## Which format to use

* [`/decide`](https://docs.levanto.ai/decision-model/quickstart) is Sage's own format: all five decision kinds, `null` when Sage isn't sure, [reasoning](https://docs.levanto.ai/decision-model/reasoning.md) and [grounding](https://docs.levanto.ai/decision-model/grounding.md). Start here.
* `/v1/decisions` is for code and frameworks that speak OpenAI's format, and for judging a conversation with tool calls, as in [Guard tool calls](https://docs.levanto.ai/decision-model/tool-calls.md).
* [`/v1/systemone`](https://docs.levanto.ai/systemone) is for code and frameworks that speak the SystemOne format.

## Request

```bash theme={"theme":"github-light"}
curl -s https://api.levanto.ai/v1/decisions \
  -H "Authorization: Bearer $LEVANTO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "sage-latest",
  "input": "I was charged twice for my order. Please refund the duplicate today.",
  "questions": [
    {"type": "predicate", "name": "refund", "instructions": "The customer asks for money back."},
    {"type": "choice", "name": "team", "instructions": "Which team should handle this?",
     "choices": [{"value": "billing"}, {"value": "technical"}, {"value": "shipping"}]},
    {"type": "score", "name": "urgency", "instructions": "How urgent is it?",
     "levels": [{"label": "Can wait"}, {"label": "This week"}, {"label": "Today"}]}
  ]
}'
```

## Response

`answers` follows the order of `questions`.

```json theme={"theme":"github-light"}
{
  "answers": [
    {"type": "predicate", "name": "refund", "probability": 0.9494},
    {"type": "choice", "name": "team", "choice": "billing", "confidence": 0.9998,
     "probabilities": [{"value": "billing", "probability": 0.9998},
                       {"value": "technical", "probability": 0.0001},
                       {"value": "shipping", "probability": 0.0001}]},
    {"type": "score", "name": "urgency", "score": 1.99, "confidence": 0.9929,
     "probabilities": [{"value": 0, "label": "Can wait", "probability": 0.0017},
                       {"value": 1, "label": "This week", "probability": 0.0055},
                       {"value": 2, "label": "Today", "probability": 0.9929}]}
  ],
  "model": "levanto-sage-2",
  "usage": {
    "input_tokens": 192,
    "input_tokens_details": {"cached_tokens": 0, "cache_write_tokens": 0},
    "output_tokens": 0,
    "output_tokens_details": {"reasoning_tokens": 0},
    "total_tokens": 192
  }
}
```

## Questions

| `type` | Sage kind | Takes | Answer |
| - | - | - | - |
| `predicate` | [Yes/No](https://docs.levanto.ai/decision-model/yesno.md) | `instructions`: the statement to judge | `probability` that it's true |
| `choice` | [Choice](https://docs.levanto.ai/decision-model/choice.md) | `choices`: `{"value", "description"}` | `choice`, `confidence`, `probabilities` |
| `score` | [Scale](https://docs.levanto.ai/decision-model/scale.md) | `levels`: `{"label", "description"}`, lowest first | `score` from 0, `confidence`, `probabilities` |

Every question takes an optional `name`, returned with its answer. Each `probabilities` list sums to 1, and `confidence` is its highest value.

## Input

`input` is text, or a list of items in conversation order:

| Item | Shape |
| - | - |
| Message | `role` (`user`, `developer`, `system` or `assistant`) and `content`: text, or a list of `input_text`, `input_image` and `input_json` parts |
| Tool call | `function_call` with `call_id`, `name` and `arguments`, or `custom_tool_call` with `call_id`, `name` and `input` |
| Tool result | `function_call_output` or `custom_tool_call_output`, with the `call_id` of its call and the `output` |

Tool calls and their results are read as turns of the conversation. An image is an `input_image` part whose `image_url` is a base64 `data:` URI:

```json theme={"theme":"github-light"}
{"role": "user", "content": [
  {"type": "input_text", "text": "Screenshot attached to a support ticket."},
  {"type": "input_image", "image_url": "data:image/png;base64,iVBORw0KGgo..."}
]}
```

`prompt_cache_key`, `prompt_cache_options`, `safety_identifier` and an image's `detail` are accepted and ignored.

## Differences

* Every question gets an answer, never `null`. Set your own threshold, or use [`/decide`](https://docs.levanto.ai/decision-model/quickstart) to get `null` when Sage isn't sure.
* Sort, Tags, reasoning and grounding are on `/decide` and [`/v1/systemone`](https://docs.levanto.ai/systemone). Any other field in the body returns 400.
* Errors use OpenAI's error body. See [Errors](https://docs.levanto.ai/reference/errors.md#openai-decisions).

Question, option and image limits: [Limits](https://docs.levanto.ai/decision-model/limits.md#openai-decisions).


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