API REFERENCE
Decisions API
Score text choices, ordered levels and yes/no questions with measured input-only usage.
Overview
Use POST https://api.netraruntime.com/v1/decisions to score a fixed set of text labels with deepseek/deepseek-v4.1-flash. Authenticate with Authorization: Bearer $NETRA_API_KEY. This is a Netra-specific endpoint, separate from Anthropic Messages and OpenAI Chat/Responses.
V4.1 Flash supports choice, score and yes/no questions. Each request returns probabilities for your supplied labels, rather than a generated answer.
Request and example
curl https://api.netraruntime.com/v1/decisions \
-H "Authorization: Bearer $NETRA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek/deepseek-v4.1-flash",
"input": "The package arrived damaged, but support replaced it promptly.",
"questions": [
{"id":"sentiment","type":"choice","question":"What is the overall sentiment?",
"options":[{"name":"positive"},{"name":"mixed"},{"name":"negative"}]},
{"id":"resolution","type":"score","question":"How well was the problem resolved?",
"levels":["unresolved","partially resolved","fully resolved"]},
{"id":"damage","type":"yes_no","question":"Was the package damaged?"}
]
}'model, input and questions are required. Use text for input and each question; structured JSON arrays/objects are also accepted as textual context, not image/file attachments. Question IDs must be nonempty and unique.
| Question type | Fields | Meaning |
|---|---|---|
choice | 2–26 options, each with a nonempty name and optional description | Scores the options and returns the most probable option as choice. Names must be unique after trimming and Unicode case folding, and cannot contain control characters. |
score | 2–10 ordered levels | Returns probabilities for the levels and score, the expected zero-based level index. For three levels the range is 0–2, not 1–3. |
yes_no | Optional yes and no descriptions | Returns probabilities for yes and no. |
Optional temperature must be greater than zero and changes the distribution over the supplied labels. prompt_format_version supports only 1. The only supported template control is chat_template_kwargs: {"thinking_mode":"chat"}. Your organization’s access restrictions remain applicable.
This endpoint does not support stream, max_tokens, tools, thinking generation or image inputs. If supplied, images must be an empty array. Unknown fields fail validation.
Response and interpretation
An illustrative yes/no response has this shape; these probabilities are example values, not a live result:
{
"object": "decisions",
"model": "deepseek/deepseek-v4.1-flash",
"prompt_format_version": 1,
"answers": {
"damage": {
"type": "yes_no",
"probabilities": {"yes": 0.9, "no": 0.1},
"label_mass": 0.5
}
},
"usage": {"prompt_tokens": 120, "completion_tokens": 0, "total_tokens": 120}
}answers is keyed by your question IDs. Each probability distribution sums to one over the supplied labels. It is not a calibrated probability that the underlying real-world claim is true. label_mass measures the labels' raw probability mass in the model vocabulary before temperature normalization; a low value is useful diagnostic information, not automatically an incorrect decision.
return_prompt_token_ids: true includes diagnostic prompt token IDs when available. Token IDs can reconstruct input content: treat this optional response as sensitive, and avoid logging it. They are not conversation IDs or a replay mechanism.
Limits, billing and errors
- Maximum JSON body: 2 MiB. Supply 1–32 questions. The aggregate prompt limit is 1,048,576 tokens, with your model’s context limit also applying.
- Each question repeats the input in its own model prompt. Usage adds the measured input tokens across all questions, including formatting and label instructions. Splitting one request into many questions can therefore increase cost substantially.
- Existing organization credits, prices, API-key permissions and spending/rate limits apply. Credit is reserved while the request runs, and the final charge uses measured input usage. It does not bill the JSON probability response as generated output.
completion_tokensis zero. - If scoring is unavailable or fails, the API returns an error. It does not substitute a generated answer.
400means invalid input/unsupported capability;401invalid credentials;402insufficient credit;403permission denied;404unavailable model;413body limit;429rate/capacity limit;502invalid or incomplete upstream response;503scoring temporarily unavailable;504timeout. HonourRetry-Afterwhen present.- Preserve
X-Request-Idwhen correlating the response with Observe. Recording is off by default; optional recordings are scheduled for deletion after 30 days.
Python and JavaScript
Use a normal HTTP client. Anthropic SDK messages.create and OpenAI SDK chat.completions.create do not invoke Decisions.
Install httpx with pip install httpx for the Python example. The JavaScript example uses the built-in fetch in Node.js 18 or newer.
import os
import httpx
response = httpx.post(
"https://api.netraruntime.com/v1/decisions",
headers={"Authorization": f"Bearer {os.environ['NETRA_API_KEY']}"},
json={"model": "deepseek/deepseek-v4.1-flash", "input": "Jakarta is in Indonesia.",
"questions": [{"id": "fact", "type": "yes_no", "question": "Is Jakarta in Indonesia?"}]},
timeout=140,
)
response.raise_for_status()
print(response.json()["answers"]["fact"])const response = await fetch("https://api.netraruntime.com/v1/decisions", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.NETRA_API_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({ model: "deepseek/deepseek-v4.1-flash", input: "Jakarta is in Indonesia.",
questions: [{ id: "fact", type: "yes_no", question: "Is Jakarta in Indonesia?" }] }),
signal: AbortSignal.timeout(140_000),
});
if (!response.ok) throw new Error(`Decisions HTTP ${response.status}`);
console.log((await response.json()).answers.fact);