Decisions API
This page documents the 4 gateway endpoints tagged decisions in the gateway's OpenAPI document. Every example targets a gateway on http://localhost:4000 and authenticates with the SPANWAY_API_KEY environment variable, which holds the master key or a virtual key that has access to the route. Request and response fields are taken from the schema the running gateway publishes at /openapi.json, and the same document is bundled with this site as openapi.json.
| Method | Path | Summary |
|---|---|---|
| POST | /decisions | Ask questions about an input (OpenAI Decisions format) |
| POST | /systemone | Ask named questions about a state (System One format) |
| POST | /v1/decisions | Ask questions about an input (OpenAI Decisions format) |
| POST | /v1/systemone | Ask named questions about a state (System One format) |
Endpoints
POST /decisions
Ask questions about an input (OpenAI Decisions format)
Judge an input against 1 to 128 questions and get the answers back in the same order.
Use it when your app needs a quick, scored judgement instead of free text, for example "is this a refund request, and how urgent is it". Any virtual key allowed to use the named model may call it. Nothing is stored beyond the usual request log and spend tracking, and the key's budget and rate limits apply.
Question types are predicate (yes/no with probability), choice (one of the choices, with
probabilities) and score (an index into levels, with probabilities). Requests that break these
rules are rejected with a 400 before any provider is called. model is any decision model in the proxy
model list. System One decision models accept this format too, Spanway translates the request and the
answers. Streaming is not supported.
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
audio | array of string or object | No | Clef-omni only. Up to 4 embedded audio clips, each a base64 data URL or {content_type, base64} |
input | string or array of object | Yes | The text being judged, or user messages whose content mixes input_text and input_image parts |
model | string | Yes | A decision model from the proxy model_list |
questions | array of object | Yes | Predicate, choice and score questions. Answers come back in the same order |
safety_identifier | string or null | No | A stable end-user id for OpenAI. Other providers answer 400 unless drop_params is true |
videos | array of string or object | No | Clef-omni only. Up to 2 embedded videos, each a base64 data URL or {content_type, base64} |
Example request:
curl -X POST "http://localhost:4000/decisions" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": "Customer wrote: I was charged twice for order #4411 and want one charge refunded today.",
"model": "luna",
"questions": [
{
"instructions": "Is the customer asking for a refund?",
"name": "is_refund_request",
"type": "predicate"
},
{
"choices": [
{
"description": "can wait a week",
"value": "low"
},
{
"description": "needs action today",
"value": "high"
}
],
"instructions": "How urgent is this?",
"name": "urgency",
"type": "choice"
},
{
"instructions": "How frustrated is the customer?",
"levels": [
{
"label": "calm"
},
{
"label": "mildly annoyed"
},
{
"label": "angry"
}
],
"name": "frustration",
"type": "score"
}
]
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | One answer per question, in the order they were asked | application/json OpenAIDecisionResponse |
| 400 | The request was refused before any provider was called: the body breaks a question rule, stream is true, or the model is not in the model list. error.message says which. Docs | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
answers | array of OpenAIPredicateAnswer or OpenAIChoiceAnswer or OpenAIScoreAnswer or OpenAIRefusalAnswer | Yes | Answers |
model | string | Yes | Model |
usage | OpenAIDecisionUsage | Yes |
POST /systemone
Ask named questions about a state (System One format)
Judge a state against 1 to 128 named questions and get one calibrated answer per question name.
Use it when your app needs a quick, scored judgement instead of free text, for example "is this a refund request, and how urgent is it". Any virtual key allowed to use the named model may call it. Nothing is stored beyond the usual request log and spend tracking, and the key's budget and rate limits apply.
Question types are noul (probability the answer is yes), choice (one label out of criteria, with
confidence and probabilities) and score (an index into the criteria levels, with confidence,
legend and probabilities). Requests that break these rules are rejected with a 400 before any provider
is called. model is any decision model in the proxy model list. OpenAI decision models accept this format
too, Spanway translates it and keeps the answers keyed by question name. Streaming is not supported.
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
audio | array of string or object | No | Clef-omni only. Up to 4 embedded audio clips, each a base64 data URL or {content_type, base64} |
model | string | Yes | A decision model from the proxy model_list |
questions | object | Yes | Named noul, choice and score questions. Each key becomes a key in the answers |
state | string or object or array of any | Yes | The thing being judged, such as a support ticket, a document or a chat transcript |
videos | array of string or object | No | Clef-omni only. Up to 2 embedded videos, each a base64 data URL or {content_type, base64} |
Example request:
curl -X POST "http://localhost:4000/systemone" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "jev",
"questions": {
"frustration": {
"criteria": [
"calm",
"mildly annoyed",
"angry"
],
"instructions": "How frustrated is the customer?",
"type": "score"
},
"is_refund_request": {
"instructions": "Is the customer asking for a refund?",
"type": "noul"
},
"urgency": {
"criteria": {
"high": "needs action today",
"low": "can wait a week"
},
"instructions": "How urgent is this?",
"type": "choice"
}
},
"state": "Customer wrote: I was charged twice for order #4411 and want one charge refunded today."
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | One answer per question name | application/json DecisionsResponse |
| 400 | The request was refused before any provider was called: the body breaks a question rule, stream is true, or the model is not in the model list. error.message says which. Docs | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
answers | object | Yes | Answers |
model | string or null | No | Model |
usage | DecisionsUsage or null | No |
POST /v1/decisions
Ask questions about an input (OpenAI Decisions format)
Judge an input against 1 to 128 questions and get the answers back in the same order.
Use it when your app needs a quick, scored judgement instead of free text, for example "is this a refund request, and how urgent is it". Any virtual key allowed to use the named model may call it. Nothing is stored beyond the usual request log and spend tracking, and the key's budget and rate limits apply.
Question types are predicate (yes/no with probability), choice (one of the choices, with
probabilities) and score (an index into levels, with probabilities). Requests that break these
rules are rejected with a 400 before any provider is called. model is any decision model in the proxy
model list. System One decision models accept this format too, Spanway translates the request and the
answers. Streaming is not supported.
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
audio | array of string or object | No | Clef-omni only. Up to 4 embedded audio clips, each a base64 data URL or {content_type, base64} |
input | string or array of object | Yes | The text being judged, or user messages whose content mixes input_text and input_image parts |
model | string | Yes | A decision model from the proxy model_list |
questions | array of object | Yes | Predicate, choice and score questions. Answers come back in the same order |
safety_identifier | string or null | No | A stable end-user id for OpenAI. Other providers answer 400 unless drop_params is true |
videos | array of string or object | No | Clef-omni only. Up to 2 embedded videos, each a base64 data URL or {content_type, base64} |
Example request:
curl -X POST "http://localhost:4000/v1/decisions" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": "Customer wrote: I was charged twice for order #4411 and want one charge refunded today.",
"model": "luna",
"questions": [
{
"instructions": "Is the customer asking for a refund?",
"name": "is_refund_request",
"type": "predicate"
},
{
"choices": [
{
"description": "can wait a week",
"value": "low"
},
{
"description": "needs action today",
"value": "high"
}
],
"instructions": "How urgent is this?",
"name": "urgency",
"type": "choice"
},
{
"instructions": "How frustrated is the customer?",
"levels": [
{
"label": "calm"
},
{
"label": "mildly annoyed"
},
{
"label": "angry"
}
],
"name": "frustration",
"type": "score"
}
]
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | One answer per question, in the order they were asked | application/json OpenAIDecisionResponse |
| 400 | The request was refused before any provider was called: the body breaks a question rule, stream is true, or the model is not in the model list. error.message says which. Docs | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
answers | array of OpenAIPredicateAnswer or OpenAIChoiceAnswer or OpenAIScoreAnswer or OpenAIRefusalAnswer | Yes | Answers |
model | string | Yes | Model |
usage | OpenAIDecisionUsage | Yes |
POST /v1/systemone
Ask named questions about a state (System One format)
Judge a state against 1 to 128 named questions and get one calibrated answer per question name.
Use it when your app needs a quick, scored judgement instead of free text, for example "is this a refund request, and how urgent is it". Any virtual key allowed to use the named model may call it. Nothing is stored beyond the usual request log and spend tracking, and the key's budget and rate limits apply.
Question types are noul (probability the answer is yes), choice (one label out of criteria, with
confidence and probabilities) and score (an index into the criteria levels, with confidence,
legend and probabilities). Requests that break these rules are rejected with a 400 before any provider
is called. model is any decision model in the proxy model list. OpenAI decision models accept this format
too, Spanway translates it and keeps the answers keyed by question name. Streaming is not supported.
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
audio | array of string or object | No | Clef-omni only. Up to 4 embedded audio clips, each a base64 data URL or {content_type, base64} |
model | string | Yes | A decision model from the proxy model_list |
questions | object | Yes | Named noul, choice and score questions. Each key becomes a key in the answers |
state | string or object or array of any | Yes | The thing being judged, such as a support ticket, a document or a chat transcript |
videos | array of string or object | No | Clef-omni only. Up to 2 embedded videos, each a base64 data URL or {content_type, base64} |
Example request:
curl -X POST "http://localhost:4000/v1/systemone" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "jev",
"questions": {
"frustration": {
"criteria": [
"calm",
"mildly annoyed",
"angry"
],
"instructions": "How frustrated is the customer?",
"type": "score"
},
"is_refund_request": {
"instructions": "Is the customer asking for a refund?",
"type": "noul"
},
"urgency": {
"criteria": {
"high": "needs action today",
"low": "can wait a week"
},
"instructions": "How urgent is this?",
"type": "choice"
}
},
"state": "Customer wrote: I was charged twice for order #4411 and want one charge refunded today."
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | One answer per question name | application/json DecisionsResponse |
| 400 | The request was refused before any provider was called: the body breaks a question rule, stream is true, or the model is not in the model list. error.message says which. Docs | application/json ProxyError |
| 401 | No valid key was sent, or the key has expired or is blocked. | application/json ProxyError |
| 403 | The key is valid but may not use this model, route or feature. A guardrail block is a 400, not a 403. | application/json ProxyError |
| 404 | The route or resource does not exist, or this key cannot see it. An unknown model name is a 400 (Invalid model name passed in model=...). | application/json ProxyError |
| 408 | The provider did not answer before the request timed out. | application/json ProxyError |
| 413 | The request body is larger than max_request_size_mb (100 MB by default), or an upload is larger than its own limit. The gateway refused it before reading the key. Docs | application/json object |
| 422 | The request body does not have the expected shape, or a budget (key, user, team, organization or end user) is used up: error.type is budget_exceeded. The budget status is spanway_settings.budget_exceeded_status_code, 422 by default. With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError or HTTPValidationError |
| 429 | Too many requests. A provider limit or a gateway limit (requests or tokens per minute, or parallel requests) refused the call, and error.type says which. A gateway limit also sends the RateLimit headers and x-spanway-rate-limited-by. Docs With access requests licensed, a key or team limit refusal also carries error.request_increase, which names the access request to file for a higher limit. Ask from an error | application/json ProxyError |
| 500 | The gateway or the provider failed unexpectedly, or the gateway could not reach the provider. Retry, and quote the request id if it keeps failing. | application/json ProxyError |
| 502 | The provider, or a proxy in front of it, answered with something that is not a valid response. | application/json ProxyError |
| 503 | The provider is overloaded or unavailable. With Redis rate limiting, a 503 also means the gateway could not check the rate limit counters and refused the request, because fail_closed_rate_limit_enforcement is on. Docs | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
answers | object | Yes | Answers |
model | string or null | No | Model |
usage | DecisionsUsage or null | No |