codai docs
API referenceGateway

System One

Typed, calibrated decisions from codai-s1 in one forward pass — choice, score and yes/no questions.

codai-s1 answers typed questions about a state without generating text, typically in 80–300 ms. Gate your action on the returned confidence, and keep your own fallback: when the model is unavailable the gateway answers 503 s1_unavailable and never substitutes a generative model unless you ask for it.

  • Batch — send items: [{ id, state }] (up to 16) instead of state to ask the same questions about several states at once; the answer is items: [{ id, answers }] in request order (client.systemOne.batch(...) / client.system_one.batch(...)).
  • timeout_ms — 100–5000 ms budget for this call (default 1500).
  • fallback: "codai-fast" — opt in to a generative fallback: when codai-s1 is unavailable, codai-fast answers the same questions with the same answer shapes, and the response carries fallback_used: true (plus the x-codai-s1-fallback header). Its probabilities are less calibrated, so lower your thresholds or log the flag.
POST
/v1/systemone

Authorization

bearerAuth
headerAuthorizationBearer <codai_…>

A codai API key (codai_ prefix). Ephemeral tokens from POST /v1/tokens are accepted only by the media surfaces matching their scope (/v1/realtime, /v1/audio/*, /v1/embeddings).

Header Parameters

x-request-id?string

Client correlation id; echoed back as x-codai-trace-id and persisted on the usage row.

Lengthlength <= 128
x-codai-session-id?string

Groups requests of one conversation for receipts, stickiness and prompt caching.

Lengthlength <= 128

Request Body

application/json
  1. body

Send exactly one of state (single) or items (batch).

state?||array<unknown>

Text, JSON object or array the questions are about (≤ 64 000 chars serialised).

items?array<>

Batch mode — the same questions asked about each item's state, concurrently. Ids must be unique.

Items1 <= items <= 16
questions*

1-32 questions keyed by an id you choose; answers come back under the same ids.

timeout_ms?integer

codai-s1 budget for this call in milliseconds (default set by the gateway, 1500).

Range100 <= value <= 5000
fallback?string

codai-fast lets the gateway answer with codai-fast (structured output) when codai-s1 is unavailable; the response then has fallback_used: true.

Default"none"
Value in"none""codai-fast"
model?string

Accepted for symmetry; only codai-s1 is served.

Response Body

One typed answer per question id (answers), or per item and question id (items) for a batch.

application/json
  1. response

answers for a single state, items for a batch.

model*string

codai-s1, or codai-fast when the opt-in fallback answered.

answers?
items?array<>

Batch results in request order.

usage*
latency_ms*integer
fallback_used?boolean

Present and true only when codai-s1 was unavailable and the opt-in codai-fast fallback answered.

Example Request
curl -X POST 'https://ai.codai.ro/v1/systemone' \  -H 'Content-Type: application/json' \  -d '{  "questions": {    "property1": {      "type": "choice",      "instructions": "string"    },    "property2": {      "type": "choice",      "instructions": "string"    }  }}'
Example Response
{  "model": "string",  "answers": {    "property1": {      "type": "choice",      "choice": "string",      "score": 0,      "noul": 0,      "confidence": 0,      "probabilities": {        "property1": 0,        "property2": 0      },      "legend": {        "property1": "string",        "property2": "string"      }    },    "property2": {      "type": "choice",      "choice": "string",      "score": 0,      "noul": 0,      "confidence": 0,      "probabilities": {        "property1": 0,        "property2": 0      },      "legend": {        "property1": "string",        "property2": "string"      }    }  },  "items": [    {      "id": "string",      "answers": {        "property1": {          "type": "choice",          "choice": "string",          "score": 0,          "noul": 0,          "confidence": 0,          "probabilities": {            "property1": 0,            "property2": 0          },          "legend": {            "property1": "string",            "property2": "string"          }        },        "property2": {          "type": "choice",          "choice": "string",          "score": 0,          "noul": 0,          "confidence": 0,          "probabilities": {            "property1": 0,            "property2": 0          },          "legend": {            "property1": "string",            "property2": "string"          }        }      }    }  ],  "usage": {    "input_tokens": 0,    "output_tokens": 0  },  "latency_ms": 0,  "fallback_used": true}

Last updated: