# Decisions

> The same System One read in OpenAI's Decisions format. Point an OpenAI SDK at Codiv and call decisions.create.

Source: https://codiv.ai/docs/api-reference/decisions

## Create a decision

Endpoint:


```text
POST https://api.codiv.ai/v1/decisions
```

Takes OpenAI's [Decisions API](https://developers.openai.com/api/docs/guides/decisions) request and answers it with the same read as [`/v1/systemone`](https://codiv.ai/docs/api-reference/system-one.md): the same questions get the same answers. Authenticate with `Authorization: Bearer <key>`. Usage counts toward your System One quota.

### Request body

- `model` (string, required)

  Any System One model: `openjev-latest`, or any id from [List models](https://codiv.ai/docs/api-reference/models.md). OpenAI's own model names answer `400`.

- `input` (string or array, required)

  What the questions are about: a string, or `user` messages whose content is a string or a list of `input_text` and `input_image` parts. Texts are joined with blank lines. An `input_image` must be a `data:image/…;base64,` URL; hosted URLs and `file_id` aren't supported. Images have the same limits as on [`/v1/systemone`](https://codiv.ai/docs/guides/images.md), and only `openjev-latest` and `clef-flash-1.0` take them.

- `questions` (array, required)

  The questions, answered in this order.

  Question object properties:

  - `type` ("predicate", "choice" or "score", required)

    `predicate` is a yes/no question (a `noul` on `/v1/systemone`).

  - `name` (string, optional)

    Returned with the answer. Names must be unique, and the model never sees them.

  - `instructions` (string, optional)

    What to decide about the input.

  - `choices` (array, choice only)

    `[{"value": ..., "description": ...}]`, 1 to 255 options (24 on `verdict-1.4`). A value is a string or a boolean.

  - `levels` (array, score only)

    `[{"label": ..., "description": ...}]`, 2 to 10 levels ordered from lowest to highest. The model reads each level as `label: description`.

The OpenJev [read options](https://codiv.ai/docs/guides/read-options.md) `steps`, `samples`, `think` and `sequential` work here too.

### Returns

A decision object. Errors use OpenAI's `{"error": {"message", "type", "param", "code"}}`.

Python:

```python
from openai import OpenAI

client = OpenAI(base_url="https://api.codiv.ai/v1", api_key="sk-codiv-...")
d = client.decisions.create(
    model="openjev-latest",
    input="Hi, my Stripe connection keeps failing with a 403 and we launch tomorrow.",
    questions=[
        {"type": "predicate", "name": "is_urgent", "instructions": "The message conveys urgency"},
        {"type": "choice", "name": "department", "instructions": "Which team should handle this",
         "choices": [{"value": "billing", "description": "Payment or subscription issues"},
                     {"value": "technical", "description": "Bugs or integration problems"},
                     {"value": "sales", "description": "Pricing or account questions"}]},
        {"type": "score", "name": "frustration", "instructions": "How frustrated the customer appears",
         "levels": [{"label": "calm"}, {"label": "frustrated"}, {"label": "angry"}]},
    ],
)
print(d.answers[1].choice)  # "technical"
```

curl:

```bash
curl https://api.codiv.ai/v1/decisions \
  -H "Authorization: Bearer $CODIV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openjev-latest",
    "input": "Hi, my Stripe connection keeps failing with a 403 and we launch tomorrow.",
    "questions": [
      {"type": "predicate", "name": "is_urgent", "instructions": "The message conveys urgency"},
      {"type": "choice", "name": "department", "instructions": "Which team should handle this",
       "choices": [{"value": "billing"}, {"value": "technical"}, {"value": "sales"}]}
    ]
  }'
```

## The decision object

- `model` (string)

  The exact model version that answered, for example `openjev-0.1`.

- `answers` (array)

  One answer per question, in question order, each with the question's `name` when it has one.

  predicate answer:

  - `probability` (number)

    Probability of yes, between 0 and 1.

  choice answer:

  - `choice` (string or boolean)

    The most likely value.

  - `probabilities` (array)

    `[{"value", "probability"}]` for every option, in the order you sent them. The probabilities sum to 1.

  - `confidence` (number)

    `1 − H(p)/ln K`: 1 when certain and 0 when uniform. See [Probabilities & confidence](https://codiv.ai/docs/guides/confidence.md).

  score answer:

  - `score` (number)

    The expected level, `Σ i·pᵢ`, with levels numbered from 0.

  - `probabilities` (array)

    `[{"value", "label", "probability"}]` for every level.

  - `confidence` (number)

    As for choice.

- `usage` (object)

  `input_tokens` counts against your quota, and so does `output_tokens`, which is 0 unless you set `think`. Cached tokens are always 0.

Decision:

```json
{"model": "openjev-0.1",
 "answers": [
   {"type": "predicate", "name": "is_urgent", "probability": 0.9974},
   {"type": "choice", "name": "department", "choice": "technical",
    "probabilities": [{"value": "billing", "probability": 0.0016},
                      {"value": "technical", "probability": 0.9979},
                      {"value": "sales", "probability": 0.0004}],
    "confidence": 0.9856}],
 "usage": {"input_tokens": 120, "output_tokens": 0, "total_tokens": 120,
           "input_tokens_details": {"cached_tokens": 0, "cache_write_tokens": 0},
           "output_tokens_details": {"reasoning_tokens": 0}}}
```

System One models never refuse a question, so no answer is a `refusal`.
