# Codiv developer platform

> Codiv runs open System One models. They answer typed questions about your data with a calibrated probability for every option, in milliseconds, instead of generating text.

Source: https://codiv.ai/docs

You send a **state**, such as a support ticket, a log line, a document or any JSON, together with questions of three types: **noul** (yes/no), **choice** (pick a label) and **score** (a point on a scale). Codiv returns the full distribution for each question, so you can route, filter and escalate on thresholds you choose. The first model on Codiv is [OpenJev](https://codiv.ai/docs/models.md), which is open weights and open source.

- [Quickstart](https://codiv.ai/docs/quickstart.md): Make your first request in under five minutes.
- [Writing questions](https://codiv.ai/docs/guides/questions.md): noul, choice and score, and how to phrase them.
- [API reference](https://codiv.ai/docs/api-reference/system-one.md): Every field of `POST /v1/systemone`.
- [Coming from Jev?](https://codiv.ai/docs/guides/jev-compatibility.md): Keep your SDK and change one URL.

## A first request

curl:

```bash
curl https://api.codiv.ai/v1/systemone \
  -H "Authorization: Bearer $TYPESAFE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openjev-latest",
    "state": "Hi, my Stripe connection keeps failing with a 403 and we launch tomorrow.",
    "questions": {
      "department": {
        "type": "choice",
        "instructions": "Which team should handle this",
        "criteria": {
          "billing": "Payment or subscription issues",
          "technical": "Bugs or integration problems",
          "sales": "Pricing or account questions"
        }
      },
      "frustration": {
        "type": "score",
        "instructions": "How frustrated the customer appears",
        "criteria": ["Calm, just stating facts", "Frustrated but civil", "Very angry, strong language"]
      },
      "is_urgent": {"type": "noul", "instructions": "The message conveys urgency"}
    }
  }'
```

Python:

```python
from typesafe_sdk import Choice, Noul, Score, TypeSafeClient

# Reads TYPESAFE_API_KEY and TYPESAFE_BASE_URL=https://api.codiv.ai
client = TypeSafeClient()

response = client.system_one(
    "Hi, my Stripe connection keeps failing with a 403 and we launch tomorrow.",
    {
        "department": Choice(
            instructions="Which team should handle this",
            criteria={
                "billing": "Payment or subscription issues",
                "technical": "Bugs or integration problems",
                "sales": "Pricing or account questions",
            },
        ),
        "frustration": Score(
            instructions="How frustrated the customer appears",
            criteria=["Calm, just stating facts", "Frustrated but civil", "Very angry, strong language"],
        ),
        "is_urgent": Noul(instructions="The message conveys urgency"),
    },
    model="openjev-latest",
)

print(response.choices["department"].choice)   # "technical"
print(response.scores["frustration"].score)     # 1.0
print(response.nouls["is_urgent"].noul)        # 1.0
```

TypeScript:

```ts
import { TypeSafeClient, choice, noul, score } from "@typesafe-ai/sdk";

// Reads TYPESAFE_API_KEY; baseURL can also come from TYPESAFE_BASE_URL
const client = new TypeSafeClient({ baseURL: "https://api.codiv.ai" });

const response = await client.systemOne({
  model: "openjev-latest",
  state: "Hi, my Stripe connection keeps failing with a 403 and we launch tomorrow.",
  questions: {
    department: choice("Which team should handle this", {
      billing: "Payment or subscription issues",
      technical: "Bugs or integration problems",
      sales: "Pricing or account questions",
    }),
    frustration: score("How frustrated the customer appears", [
      "Calm, just stating facts",
      "Frustrated but civil",
      "Very angry, strong language",
    ]),
    is_urgent: noul("The message conveys urgency"),
  },
});

console.log(response.answers.department.choice); // "technical"
```

Response:

```json
{
  "model": "openjev-0.1",
  "answers": {
    "department": {
      "type": "choice",
      "choice": "technical",
      "probabilities": {"billing": 0.0, "technical": 1.0, "sales": 0.0},
      "confidence": 1.0
    },
    "frustration": {
      "type": "score",
      "score": 1.0,
      "legend": {"0": "Calm, just stating facts", "1": "Frustrated but civil", "2": "Very angry, strong language"},
      "probabilities": {"0": 0.0, "1": 1.0, "2": 0.0},
      "confidence": 0.97
    },
    "is_urgent": {"type": "noul", "noul": 1.0}
  },
  "usage": {"input_tokens": 175, "output_tokens": 0}
}
```

## When to use a System One model

- **Classification and routing**, like triage, moderation, intent or topic, when you need a label and a probability rather than prose.
- **Many decisions per item.** Ask dozens of questions about one state in a single request; they are answered in parallel.
- **Hot paths.** A request with a few questions typically finishes in under 100 ms of model time.
- **Calibrated thresholds.** Every answer is a distribution, so you decide how sure is sure enough.

Use a generative model when the output itself is text, such as drafting a reply. A common pattern pairs the two: the System One model decides *whether* and *where* something should go, and a generative model writes.

## For AI assistants

Every docs page is also available as Markdown: add `.md` to its URL, for example [/docs/quickstart.md](https://codiv.ai/docs/quickstart.md). An index of all pages is at [/llms.txt](https://codiv.ai/llms.txt), and the whole documentation in one file is at [/llms-full.txt](https://codiv.ai/llms-full.txt).
