Skip to content

Decisions & Routing

CompactifAI’s decision endpoints answer questions with a fixed set of answers (yes/no, one option from a list, a level on a scale) from the model’s token probabilities. No text is generated, so a decision is fast and costs only the input tokens. You get the probability of every answer, not just the most likely one.

Endpoint What it does
POST /v1/decisions Answers your own questions about a text. OpenAI-compatible Decisions API.
POST /v1/is-jev Says whether a prompt is a decision request, whatever its format.
POST /v1/route Grades a chat message and answers it with the cheapest model likely to get it right.

Only models that report supports_decisions: true in their capabilities (see GET /v1/models) can answer decisions. /v1/is-jev and /v1/route use the deployment’s own decision model, so you don’t pick one.

Models that can answer /v1/decisions today:

ModelModel ID
Qwen 3.8 27Bqwen-3-8-27b

Taken from the capabilities that GET /v1/models reported on 2026-12-01. The list for your account is authoritative, so call that endpoint to see what you can use.

POST /v1/decisions
import requests
API_URL = "https://api.compactif.ai/v1/decisions"
API_KEY = "your_api_key_here"
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
data = {
"model": "<decision-model>", # a model with supports_decisions: true
"input": "I was charged twice for order 5521.",
"questions": [
{
"type": "choice",
"name": "area",
"instructions": "Which team should handle this?",
"choices": [
{"value": "billing", "description": "payments and refunds"},
{"value": "technical", "description": "bugs and outages"}
]
},
{
"type": "predicate",
"name": "urgent",
"instructions": "The customer needs a reply today."
}
]
}
response = requests.post(API_URL, headers=headers, json=data)
for answer in response.json()["answers"]:
print(answer["name"], answer)

The same request with curl:

Terminal window
curl https://api.compactif.ai/v1/decisions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $COMPACTIFAI_API_KEY" \
-d '{
"model": "<decision-model>",
"input": "I was charged twice for order 5521.",
"questions": [
{
"type": "predicate",
"name": "urgent",
"instructions": "The customer needs a reply today."
}
]
}'
Parameter Type Required Description
model string Yes A model with supports_decisions: true. Any other model returns 400, and the message lists the models that support decisions.
input string or array Yes The text to judge, or a list of user messages.
questions array Yes At least one question, answered in order. Each has a type, a name and instructions.

Question types:

type Answers with Extra fields
predicate The probability that instructions is true about the input. None.
choice One of 2 to 26 values. choices: a list of {"value": ..., "description": ...}. description is optional.
score One of 2 to 10 ordered levels, lowest first. levels: a list of {"label": ...}.

The request follows OpenAI’s Decisions API and other fields are passed to the model as they are. An invalid question is rejected by the model with a 400 that explains what’s wrong.

{
"model": "<decision-model>",
"answers": [
{
"type": "choice",
"name": "area",
"choice": "billing",
"probabilities": [
{"value": "billing", "probability": 0.9},
{"value": "technical", "probability": 0.1}
],
"confidence": 0.89
},
{
"type": "predicate",
"name": "urgent",
"probability": 0.72
}
],
"usage": {
"input_tokens": 84,
"input_tokens_details": {"cached_tokens": 0},
"output_tokens": 2,
"total_tokens": 86
}
}
Field Description
model The model you sent.
answers One answer per question, in request order. A predicate answer has a probability. A choice or score answer has the most likely value, the probabilities of every value and a confidence.
usage The tokens the model read. Only input tokens are billed. Cached tokens are billed at the cached price.
POST /v1/is-jev

Says whether a prompt is a decision request: material to judge plus a question with a closed set of answers (yes/no, one option, or a level on a scale). The prompt can be JSON, a template or plain prose. Open-ended prompts (write, summarise, explain, code, chat) are not decision requests.

Use it to decide whether a prompt can go to /v1/decisions instead of a chat model.

Terminal window
curl https://api.compactif.ai/v1/is-jev \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $COMPACTIFAI_API_KEY" \
-d '{
"prompt": "contract says net 30, invoice paid day 45. late y/n"
}'
Parameter Type Required Description
prompt string Yes The prompt to check, in any format. Must not be empty. Long prompts are checked on their start and end.
{
"is-jev": true
}
POST /v1/route

Grades how hard the last message is and how costly a wrong answer would be, then sends the chat to the model with the lowest expected cost. Expected cost is the price of the call plus the chance the model is too weak, times the cost of a wrong answer. The previous message is read as context.

Model Handles
carina-60b Easy: lookups, rewrites, short factual or formatting tasks.
quasar-1-2-358b Medium: multi-step reasoning, standard coding, summarising or analysing text.
glm-5-3 Hard: deep reasoning, hard math or code, long or ambiguous multi-part tasks.

Only the models available to the deployment are used. If grading is uncertain or fails, the strongest model answers. If the chosen model fails with 429 or a 5xx, the request moves up to the next stronger model.

Terminal window
curl https://api.compactif.ai/v1/route \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $COMPACTIFAI_API_KEY" \
-d '{
"messages": [
{"role": "user", "content": "What is 17 times 23?"}
]
}'
Parameter Type Required Description
messages array Yes The conversation, as {"role": ..., "content": ...} objects with string content. At least one message.
stream boolean No Must be false or left out. Streaming is not supported.

Other fields are ignored. You don’t send a model, because the router picks it.

{
"tier": "easy",
"model": "carina-60b",
"distribution": {"easy": 0.91, "medium": 0.08, "hard": 0.01},
"stakes": {"low": 0.85, "medium": 0.13, "high": 0.02},
"uncertain": false,
"fallback": false,
"failed_models": [],
"expected_cost_usd": 0.0002,
"completion": {
"id": "chatcmpl-...",
"object": "chat.completion",
"model": "carina-60b",
"choices": [
{
"index": 0,
"message": {"role": "assistant", "content": "17 × 23 = 391."},
"finish_reason": "stop"
}
],
"usage": {"prompt_tokens": 16, "completion_tokens": 9, "total_tokens": 25}
},
"latency_ms": 812.4
}
Field Description
model The model that answered. After a failover, it is stronger than the first choice.
tier The difficulty level the answering model handles: easy, medium or hard.
distribution The probability of each difficulty level. Empty when grading failed.
stakes The probability of each stakes level (low, medium, high). Empty when grading failed.
uncertain true when the grading was not confident, so the strongest model was chosen.
fallback true when grading failed, so the strongest model was chosen.
failed_models The models tried first that failed with a retryable error.
expected_cost_usd The estimated cost of the first-choice model. null when the strongest model was chosen without a confident grading.
completion The answering model’s chat completion, unchanged.
latency_ms The time spent on grading and answering, in milliseconds.

The grading and the answer are billed separately, each at its model’s price (see Pricing).

The endpoints use the standard error object (see Error handling).

Status Meaning
400 The request is invalid: an unknown model, a model without supports_decisions, an invalid question, or stream: true on /v1/route.
401 The API key is missing or was rejected.
402 Your prepaid balance is exhausted or a spend budget is reached. See Error handling.
429 You have exceeded your rate limit. See Rate limits.
502 upstream_unavailable: the model is temporarily unavailable. Retry shortly.
503 /v1/is-jev and /v1/route only: the decision model, or every model /v1/route can answer with, is unavailable on this deployment.
  • Use the same API key and headers as the other CompactifAI endpoints. Rate limits are shared too.
  • Ask several questions about the same input in one /v1/decisions request. The input is read once.
  • Use the probabilities to set your own threshold instead of trusting the most likely answer, for example only auto-approve when probability is above 0.9.