AI Gateway

Decisions

Ask a decision model typed questions about a state and get structured answers
View as Markdown

A decision call sends a state to evaluate and a set of named questions. The model returns one typed answer for each question, so your agent reads a probability, an option, or a score instead of parsing free text. Decisions use the jev-1-13-0 model.

Make a request

Send POST ${ASTRO_GATEWAY_URL}/v1/decisions with ASTRO_GATEWAY_API_KEY as a bearer token. The OpenAI SDKs have no decisions method, so use a plain HTTP client.

curl "$ASTRO_GATEWAY_URL/v1/decisions" \
-H "Authorization: Bearer $ASTRO_GATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "jev-1-13-0",
"state": "A customer asked for a refund 3 days after buying a jacket. The policy allows refunds within 30 days.",
"questions": {
"eligible": {
"kind": "noul",
"instructions": "Is the customer eligible for a refund?"
},
"action": {
"kind": "choice",
"instructions": "What should the agent do next?",
"criteria": {
"approve": "Issue the refund",
"escalate": "Hand off to a human"
}
},
"tone": {
"kind": "score",
"instructions": "How upset is the customer?",
"criteria": ["Calm", "Frustrated", "Angry"]
}
}
}'

Request fields

FieldTypeDescription
modelstringjev-1-13-0.
statestring or objectThe situation to evaluate. Pass prose or a JSON object. Required.
questionsobjectNamed questions. Each key is the name its answer comes back under.

Each question takes a kind, instructions, and, for some kinds, criteria:

kindAskscriteria
noulA yes-or-no questionNot used
choiceWhich one option appliesRequired. An object that maps each option name to a description.
scoreWhere the state sits on a scaleRequired. An array of level descriptions, lowest first.

Response

The response carries answers, keyed by the question names you sent:

{
"model": "jev-1.13.0",
"answers": {
"eligible": { "kind": "noul", "value": 0.95 },
"action": {
"kind": "choice",
"value": "approve",
"confidence": 1,
"probabilities": { "approve": 1, "escalate": 0 }
},
"tone": {
"kind": "score",
"value": 0.02,
"confidence": 0.97,
"probabilities": { "0": 0.98, "1": 0.02, "2": 0 },
"legend": { "0": "Calm", "1": "Frustrated", "2": "Angry" }
}
},
"usage": { "prompt_tokens": 395, "completion_tokens": 63, "total_tokens": 458 }
}
  • noul: value is the probability that the answer is yes, from 0 to 1.
  • choice: value is the chosen option name. probabilities gives the weight of every option.
  • score: value is the expected level, where 0 is the first criteria entry. legend maps each level back to its description.

An agent deployed before decision models launched can’t call them yet. The gateway rejects its key because the key doesn’t allow the provider. Redeploy the agent to get a key that allows decisions.

Errors

A malformed question returns 400 with a message that names the question and the problem, such as a choice question with no criteria. Chat, embeddings, and the Responses API return an error for decision models. See Errors and limits for status codes the whole gateway shares.

Next steps