Decisions
Get typed answers your code can branch on (yes/no probabilities, picks from your options, and scores) about text, images, PDFs, audio or video in one request
Preview. The /alpha path and the request and response shape may change before this API is marked stable. See release stages.
The Decisions API runs a decision model that gives your code a structured answer instead of generated text. You send a state (the content to evaluate: text, JSON data, images, PDFs, audio or video) and a map of named, typed questions. You get back one typed answer per question: a probability of yes for a noul question, one of your options for a choice question, or a position on your scale for a score question. Answers are never free text, so there is no output to parse or validate.
Use it when your code needs to branch on a judgment: classify or route a request, check a message against a policy, score a passage for relevance, or gate an action on the model's certainty. For free-form text, use chat completions or the Responses API instead. To classify text into fixed safety categories, use the Moderation API. To read values out of content, such as an invoice number, a total or a date, use Extractions.
Requests use your Inworld API key and are billed to your Inworld account.
| Endpoint | POST https://api.inworld.ai/alpha/decisions |
| Models | Browse Decision models in the public catalog |
| Inputs | Text and JSON data on every model. Images, PDFs, audio and video on the models that list them in spec.inputModalities; see Send images, PDFs, audio and video |
| Request size | Up to 32 MiB (33,554,432 bytes) of JSON per request, base64 files included; see Limits |
| Streaming | Not supported: the whole answer set comes back in one response |
| Pricing | See the selected model in the model catalog |
| Rate limit | Per account; see Rate limits |
Choose a model
Browse inworld.ai/models and select Decisions for model IDs and pricing. To find decision models in code, call the List models API with output_modalities=decisions and send a model's id as model. Each model's spec.inputModalities lists what it accepts: text, and on some models image, file (PDF), audio and video. Find a model that takes your input shows the check in code.
Choose a decision model for typed judgments; a chat model that supports JSON output is not interchangeable with a Decisions API model. The quickstart uses typesafe/jev, which takes text only.
How it works
- Select a decision model and set
modelto its API model ID. - Send the content to evaluate in
stateand your named questions inquestions. - Read each answer under the same question ID and use it in your application logic.
Question types
Each entry in questions is keyed by an id you choose, and its answer comes back under the same id. Every question has a type and instructions. Each type defines its own criteria.
type | Asks | criteria | Answer fields |
|---|---|---|---|
noul | A yes/no question | Optional. {"true": "...", "false": "..."} describes what yes and no mean | noul: the probability of yes, from 0 to 1 |
choice | Pick one option from a set | Required. An object mapping each option to its description, or to null | choice, probabilities (sums to 1), confidence |
score | Rate on ordered levels | Required. An array of level descriptions, lowest first | score (probability-weighted level index from 0, which can land between levels), legend, probabilities, confidence |
All questions in a request are evaluated against the same state.
Quickstart
This example uses typesafe/jev.
Run these examples on your server. Set INWORLD_API_KEY to the Base64 credentials copied from Portal or the CLI; see authentication.
curl -X POST https://api.inworld.ai/alpha/decisions \
-H "Authorization: Basic $INWORLD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "typesafe/jev",
"state": "Help! My payouts have been failing for 3 days.",
"questions": {
"is_urgent": {
"type": "noul",
"instructions": "Does this convey urgency?"
},
"department": {
"type": "choice",
"instructions": "Which team should handle this?",
"criteria": {
"billing": "Payments, invoicing, refunds",
"technical": "Bugs, outages, integrations",
"sales": "Pricing, upgrades, new accounts"
}
}
}
}'import os
import requests
response = requests.post(
"https://api.inworld.ai/alpha/decisions",
headers={"Authorization": f"Basic {os.environ['INWORLD_API_KEY']}"},
json={
"model": "typesafe/jev",
"state": "Help! My payouts have been failing for 3 days.",
"questions": {
"is_urgent": {"type": "noul", "instructions": "Does this convey urgency?"},
"department": {
"type": "choice",
"instructions": "Which team should handle this?",
"criteria": {
"billing": "Payments, invoicing, refunds",
"technical": "Bugs, outages, integrations",
"sales": "Pricing, upgrades, new accounts",
},
},
},
},
timeout=60,
)
response.raise_for_status()
answers = response.json()["answers"]
print(answers["is_urgent"]["noul"], answers["department"]["choice"])const response = await fetch('https://api.inworld.ai/alpha/decisions', {
method: 'POST',
headers: {
Authorization: `Basic ${process.env.INWORLD_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'typesafe/jev',
state: 'Help! My payouts have been failing for 3 days.',
questions: {
is_urgent: { type: 'noul', instructions: 'Does this convey urgency?' },
department: {
type: 'choice',
instructions: 'Which team should handle this?',
criteria: {
billing: 'Payments, invoicing, refunds',
technical: 'Bugs, outages, integrations',
sales: 'Pricing, upgrades, new accounts',
},
},
},
}),
});
if (!response.ok) throw new Error(`${response.status}: ${await response.text()}`);
const { answers } = await response.json();
console.log(answers.is_urgent.noul, answers.department.choice);Response:
{
"model": "typesafe/jev",
"answers": {
"is_urgent": { "type": "noul", "noul": 0.95 },
"department": {
"type": "choice",
"choice": "billing",
"probabilities": { "billing": 0.88, "technical": 0.12, "sales": 0.0 },
"confidence": 0.81
}
},
"usage": { "input_tokens": 318, "output_tokens": 34 },
"metadata": {
"attempts": [
{ "model": "typesafe/jev", "status_code": 200, "duration_ms": 212.4, "success": true }
],
"generation_id": "0f5d3c4e-8f0b-4a53-9a55-2f3a6f0d8a1b",
"total_duration_ms": 212
}
}Send images, PDFs, audio and video
Put each image, PDF, audio clip or video in the state array as a typed part, beside your text. Every question evaluates the same state, so one request can ask about a photo and a voice note together.
| Input | Part in the state array | Accepted formats | Listed in spec.inputModalities as |
|---|---|---|---|
| Image | {"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,...", "detail": "auto"}} | PNG, JPEG and WebP on every model that takes images. GIF, BMP, TIFF and HEIC on some; see Image formats and detail | image |
{"type": "file", "file": {"filename": "invoice.pdf", "file_data": "data:application/pdf;base64,..."}} | PDF. filename is optional | file | |
| Audio | {"type": "input_audio", "input_audio": {"data": "<base64>", "format": "mp3"}} | format: aac, aiff, flac, mp3, ogg or wav. data is plain base64, without a data: prefix | audio |
| Video | {"type": "video_url", "video_url": {"url": "data:video/mp4;base64,..."}} | MP4, MPEG or WebM (data:video/mp4, data:video/mpeg or data:video/webm) | video |
- Send each file inline, base64-encoded, in every request that uses it. The API does not fetch links: an
http://orhttps://URL returns400. If your app has a link, download the file and send its bytes. - Put parts directly in the
statearray. A part nested deeper, such as inside an object, is treated as JSON data, not as an image or file. A top-levelimagesfield returns400. - Keep the whole request within 32 MiB. Base64 makes a file about a third larger, so the files in one request can total about 24 MiB. See Limits.
Files count as input tokens; see Billing.
Find a model that takes your input
Call the List models API with output_modalities=decisions and pick a model whose spec.inputModalities includes every input type you send. A model that doesn't list a type refuses it with 400 before it runs, for example:
{"error": {"message": "typesafe/jev does not accept audio input", "type": "invalid_request_error"}}Install the Python dependency, set your API key, and save the following as find_model.py. The examples below import it.
python -m pip install requests
export INWORLD_API_KEY="<your Base64 API key>"import os
import requests
API = "https://api.inworld.ai"
HEADERS = {"Authorization": f"Basic {os.environ['INWORLD_API_KEY']}"}
def find_model(*inputs: str) -> str:
"""Return the ID of a decision model whose spec.inputModalities include every input."""
response = requests.get(
f"{API}/llm/v1alpha/models",
headers=HEADERS,
params={"output_modalities": "decisions"},
timeout=30,
)
response.raise_for_status()
for model in response.json().get("models", []):
accepted = model.get("spec", {}).get("inputModalities", [])
if model.get("id") and set(inputs) <= set(accepted):
return str(model["id"])
raise LookupError(f"No decision model accepts {', '.join(inputs)}")
if __name__ == "__main__":
print(find_model("audio"))Run python find_model.py to print a decision model that accepts audio. In production, pick the model once, check it against your own examples, and set it in your configuration, rather than looking it up on every request.
Classify files your users send
This script sends any mix of images, PDFs, audio and video files to one decision model and asks two yes/no questions about them. It picks the part shape from the file extension, checks the request size, and prints each answer's probability. Save it as check_upload.py next to find_model.py.
import base64
import json
import sys
from pathlib import Path
from typing import Any
import requests
from find_model import API, HEADERS, find_model
MAX_REQUEST_BYTES = 32 * 1024 * 1024
IMAGE_TYPES = {
".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp",
".gif": "image/gif", ".bmp": "image/bmp", ".tif": "image/tiff", ".tiff": "image/tiff",
".heic": "image/heic",
}
AUDIO_FORMATS = {".aac": "aac", ".aiff": "aiff", ".flac": "flac", ".mp3": "mp3", ".ogg": "ogg", ".wav": "wav"}
VIDEO_TYPES = {".mp4": "video/mp4", ".mpeg": "video/mpeg", ".webm": "video/webm"}
def to_part(path: Path) -> tuple[str, dict[str, Any]]:
"""Return the input type (as spec.inputModalities names it) and the state part for a file."""
data = base64.b64encode(path.read_bytes()).decode("ascii")
suffix = path.suffix.lower()
if suffix in IMAGE_TYPES:
return "image", {"type": "image_url", "image_url": {"url": f"data:{IMAGE_TYPES[suffix]};base64,{data}"}}
if suffix == ".pdf":
return "file", {"type": "file", "file": {"filename": path.name, "file_data": f"data:application/pdf;base64,{data}"}}
if suffix in AUDIO_FORMATS:
return "audio", {"type": "input_audio", "input_audio": {"data": data, "format": AUDIO_FORMATS[suffix]}}
if suffix in VIDEO_TYPES:
return "video", {"type": "video_url", "video_url": {"url": f"data:{VIDEO_TYPES[suffix]};base64,{data}"}}
raise ValueError(f"{path.name}: the Decisions API does not take this file type")
inputs, parts = zip(*(to_part(Path(name)) for name in sys.argv[1:]))
body = json.dumps({
"model": find_model(*inputs),
"state": ["A customer attached these files to a return request.", *parts],
"questions": {
"shows_problem": {
"type": "noul",
"instructions": "Do the files show or describe a problem with the order?",
},
"wants_refund": {"type": "noul", "instructions": "Does the customer ask for a refund?"},
},
}).encode()
if len(body) > MAX_REQUEST_BYTES:
sys.exit(f"Request is {len(body)} bytes; the limit is {MAX_REQUEST_BYTES}. Send fewer or smaller files.")
response = requests.post(
f"{API}/alpha/decisions",
headers={**HEADERS, "Content-Type": "application/json"},
data=body,
timeout=60,
)
if not response.ok:
sys.exit(f"{response.status_code}: {response.text}")
answers = response.json()["answers"]
print("shows_problem:", answers["shows_problem"]["noul"])
print("wants_refund:", answers["wants_refund"]["noul"])Run it with your files, for example an iPhone photo and a voice note:
python check_upload.py photo.heic voice-note.mp3It prints two probabilities between 0 and 1. Pass a PDF (invoice.pdf) or a video (clip.mp4) the same way. On an error it prints the status and the error body; see Errors. find_model checks input types only, not image formats: if the model refuses a HEIC photo with 400, convert it to JPEG, as described in Image formats and detail.
Image formats and detail
- PNG, JPEG and WebP at
detailauto,loworhighwork on every model that listsimage.detailis optional. - GIF, BMP, TIFF and HEIC, and
detailmediumandultra_high, work on some of those models. The List models API does not show which. A model that can't take them returns400with a message that endssend a png, jpeg or webp at detail auto, low or high. To use any image model, convert HEIC photos and other formats to JPEG or PNG first; otherwise, send one test request to the model you chose. - Higher detail counts more input tokens on models that use it. Some models ignore
detail. - Some models take at most four images per request and refuse more with a
400that states the limit. Send four or fewer, or split the images across requests.
Resize or compress large photos before sending them: smaller images keep requests within the size limit and count fewer input tokens.
Check a checkout screenshot
Use image input to check a screenshot, classify a photo, or score visible evidence.
In Portal's Decisions playground, select a model labeled Images, then load Screenshot check. Add, paste or drop a screenshot into the content area and run the example. It asks whether the checkout shows an error and which next step the application should consider. The playground accepts up to four images and may resize large photos. When copying its generated code, replace the <BASE64_IMAGE_n> placeholders with your encoded image bytes.

Save the screenshot above as checkout-declined.png next to find_model.py, then save the following as check_screenshot.py:
import base64
from pathlib import Path
import requests
from find_model import API, HEADERS, find_model
image = base64.b64encode(Path("checkout-declined.png").read_bytes()).decode("ascii")
response = requests.post(
f"{API}/alpha/decisions",
headers=HEADERS,
json={
"model": find_model("image"),
"state": [
"A shopping agent took this screenshot right after it clicked Pay.",
{"type": "image_url", "image_url": {"url": f"data:image/png;base64,{image}"}},
],
"questions": {
"error_shown": {
"type": "noul",
"instructions": "Does the screenshot show an error that must be fixed before continuing?",
},
"next_step": {
"type": "choice",
"instructions": "What should the agent do next?",
"criteria": {
"continue": "The step succeeded: go on",
"retry": "A temporary problem: try again",
"change_payment": "The payment method was refused: use another",
"ask_user": "Needs information only the user knows",
},
},
},
},
timeout=60,
)
response.raise_for_status()
answers = response.json()["answers"]
print(answers["error_shown"]["noul"])
print(answers["next_step"]["choice"])Run it from the directory containing the files:
python check_screenshot.pyThe script prints a probability between 0 and 1, then one of the four next_step options. This screenshot shows a payment declined because the card expired: a useful answer should recognize the error and select change_payment. The exact probability can vary; evaluate the model on your own screenshots before choosing a threshold.
error_shown.noul is a probability, and next_step.choice is one of your supplied options. Your application defines thresholds and decides what action to take; the API does not execute the selected action.
Use the answers in your application
The response's model names the model that answered. It can be the ID you sent or a more specific version of it, and the same request can return either, so don't compare it to a fixed value. An id without a version number uses the model's current version. To stay on one version, send an id that includes its version number, when the List models API lists one for that model. metadata reports attempts, generation_id and total_duration_ms.
The example returns answers.is_urgent.noul as a probability and answers.department.choice as one of the options you supplied. Your application decides what action to take: for example, send a request classified as billing to the billing queue, and flag it for priority review when the urgency probability exceeds your chosen threshold.
Choose thresholds using examples from your own workload. The model supplies the judgment; your code defines the action and any review or escalation rules.
Limits
These limits are the same for every decision model unless the row says otherwise.
| Limit | Value | When a request goes over it |
|---|---|---|
| Request body | 32 MiB (33,554,432 bytes) of JSON, base64 files included. There is no separate per-file limit | 413 with invalid_request_error and a message that states the limit. Send fewer or smaller files, or split them across requests |
| Images per request | At most four on some models | 400 that states the limit. Send four or fewer, or split them across requests |
| Large requests at busy times | Requests that carry large files share capacity | 503 with a Retry-After header. Retry after the delay |
| Time per request | 60 seconds | 504. Retry, or send fewer or smaller files or questions |
| Requests per second | Per account; see Rate limits | 429 |
A model can still refuse a file it can't read, such as a corrupt clip, with a relayed 400 or 422 whose message describes the problem.
Errors
Check the HTTP status and response content type before parsing the body. Decisions errors use {"error": {"message": "...", "type": "..."}}. Request validation returns 400 before sending the request to a model; these errors can also include error.param, which names the field to fix. See the error example.
Model errors relayed to your application keep their HTTP status, including 422, and use the same error format. Rate-limit and server errors use generic messages. Errors for authentication, credits and your account's rate limit use a different body: 401 and 429 are plain text, and 402 has a numeric error.code. Check the content type, and preserve the status and body when reporting a failure.
The following describes error handling for the model used in the quickstart:
| Status | Meaning | What to do |
|---|---|---|
400 | Invalid request, such as invalid JSON, a missing state or questions, an unknown question type, missing criteria or too many options. For files: an input type the model doesn't list in spec.inputModalities (<model> does not accept audio input), an unsupported format or detail, a link instead of inline data, or more images than the model takes. Also returned when the workspace has zero data retention and the model cannot serve it | Fix the request as the error describes. For an input type or format, choose a model that takes it or convert the file. For zero data retention, choose another model or use a workspace without it |
401 | Missing or invalid Inworld API key | Check the Authorization header |
402 | Your account has no credits remaining | Add credits, then retry |
413 | Request body is over 32 MiB | Send fewer or smaller files, or split them across requests. See Limits |
422 | The model rejected input that passed request validation | Fix the request as the error describes |
429 | Your account's request limit (see Rate limits), or the model is rate limited | Retry with exponential backoff and jitter. Your account's limit sends no Retry-After header. A rate limit relayed from the model can include one; honor it when present |
502 | The model could not be reached or is unavailable | Retry with exponential backoff |
503, 529 | At capacity or overloaded, including too many large requests in flight at once | Retry with exponential backoff and honor Retry-After when present |
504 | No answer within the 60-second request timeout | Retry, or send fewer or smaller files or questions |
Billing
Decisions bill input tokens only: usage.input_tokens in the response. Output tokens are reported in usage.output_tokens and are not billed. Images, PDFs, audio and video count as input tokens, as the model counts them: a longer clip, a larger PDF or a higher image detail counts more. Check the model catalog, or pricing in the List models response, for the selected model's rate.
Model capabilities and limits
Use the catalog or the List models API to discover models and the inputs each accepts. The table records documented question limits for the quickstart model; other models' question limits can differ.
| Model | Question types | Input formats | Question limits | Request limits | Billing |
|---|---|---|---|---|---|
typesafe/jev | noul, choice, score | Text only: state, instructions and criteria accept strings, objects or arrays | Up to 255 choice options; 2 to 10 score levels | 32 MiB body; 60-second timeout | Input tokens only; failed or cut-off answers are not billed |