POST
Open playgroundhttps://api.decisionnode.com /v1/decidecurl https://api.decisionnode.com/v1/decide \
-H "Authorization: Bearer $DECISIONNODE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "decisionnode-latest",
"state": "Customer: I was charged twice and nobody has replied for 3 days.",
"questions": {
"route": {
"type": "choice",
"instructions": "Where should this go?",
"criteria": {
"billing": "money",
"bug": "broken",
"account": "login"
}
},
"urgency": {
"type": "score",
"instructions": "How urgent is this?",
"criteria": ["routine", "today", "urgent", "critical"]
},
"refund": {
"type": "truth",
"instructions": "Refund this automatically?"
}
}
}'Headers#
AuthorizationstringrequiredBearer dn_live_.... Keep keys on your server and read them from an environment variable such asDECISIONNODE_API_KEY.Content-Typestringrequiredapplication/json.
Request body#
modelstringrequireddecisionnode-latestordecisionnode-flash-latest, or a pinned version such asdecisionnode-1.0.statestring | object | array- The input to decide about: text, a JSON object or a JSON array. Read once and shared by every question.
imagesarray- Up to 4 images, read together with the state.
idstringrequired- Your name for the image.
media_typestringrequiredimage/jpeg,image/pngorimage/webp.datastringrequired- Base64 bytes, no
data:prefix.
questionsobjectrequired- Your question keys mapped to question objects. Answers come back under the same keys.
type"choice" | "score" | "truth" | "number"required- Fixes the answer's shape: choice, score, truth or number.
instructionsstring- What to decide, in one sentence.
criteriaobject | string[]- Choice: option key to description, required, up to 255. Score: levels lowest first, required, up to 10. Truth: optional
{"true": "...", "false": "..."}, what true and what false mean. Number: not used, the grid is the set of answers. minnumber- Number only: the lowest value. Default 0.
maxnumber- Number only: the highest value, at least
min. Default 255. stepnumber- Number only: the grid spacing, above 0. Default 1. Up to 256 values in the first release; see Number.
Response body#
{
"model": "decisionnode-1.0",
"answers": {
"route": {
"type": "choice",
"choice": "billing",
"confidence": 0.81,
"probabilities": { "account": 0.05, "billing": 0.87, "bug": 0.08 }
},
"urgency": {
"type": "score",
"score": 2.31,
"confidence": 0.47,
"legend": {
"0": "routine",
"1": "today",
"2": "urgent",
"3": "critical"
},
"probabilities": { "0": 0.01, "1": 0.09, "2": 0.48, "3": 0.42 }
},
"refund": { "type": "truth", "truth": 0.94 }
},
"usage": { "input_tokens": 62, "output_tokens": 0 }
}modelstring- The pinned version that answered, for example
decisionnode-1.0. answersobject- One answer per question key.
choice answerobjecttype,choice(one of your keys),confidence,probabilities(alphabetical by key).score answerobjecttype,score(expected level index),confidence,legend,probabilities(in level order).truth answerobjecttype("truth") andtruth, the probability that the statement is true, from 0.00 to 1.00.number answerobjecttype,number(the most probable grid value),expected(the probability-weighted mean),confidence(the probability ofnumber),probabilities(every value above 0.001, keyed by the value as a string).
usageobjectinput_tokensbilled for this request, andoutput_tokens, which is always 0.
curl https://api.decisionnode.com/v1/decide \ -H "Authorization: Bearer $DECISIONNODE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "decisionnode-latest", "state": "Customer: I was charged twice and nobody has replied for 3 days.", "questions": { "route": { "type": "choice", "instructions": "Where should this go?", "criteria": { "billing": "money", "bug": "broken", "account": "login" } }, "urgency": { "type": "score", "instructions": "How urgent is this?", "criteria": [ "routine", "today", "urgent", "critical" ] }, "refund": { "type": "truth", "instructions": "Refund this automatically?" } } }'Response headers#
| Header | Example | Meaning |
|---|---|---|
x-request-id | req_01J9Z6K4M2 | Quote it when you contact us; store it with the decision |
x-decisionnode-latency-ms | 6 | Time spent on our side, in milliseconds |
x-decisionnode-model | decisionnode-1.0 | The model version that answered, as in model |
Retry-After | 2 | Seconds to wait before retrying, sent with every 429 and 529 |
Errors#
| Status | Meaning |
|---|---|
400 | Outside a limit (options, levels, 64k tokens, a number grid the first release does not serve), an unknown model or a bad image; the message names it |
401 | Missing or invalid API key |
402 | Out of credit; add credit in the console, then retry. Not billed. See Errors |
403 | Refused by the safety check (safety_refusal); rolling out in shadow mode, see Errors |
422 | The body failed validation; detail lists each invalid field |
429 | Rate limited; wait for Retry-After |
529 | Overloaded; wait for Retry-After, then retry |
Bodies, retry rules and code are in Errors.