Structured Evaluation (System One)
Troubleshooting
Run into an error? See the API Error Code Reference for a full description of error types and how to resolve them.
POST /api/v1/systemoneThe System One endpoint evaluates a piece of state (the content to evaluate) against a set of typed questions that you define, and returns one structured answer per question. Answers map back to questions by the keys you choose.
The semantics of state, questions, and assets follow the TypeSafe System One API. When calling through ZenMux, use the endpoint above, a ZenMux API key, and a ZenMux model ID.
Each question is one of four types, and you can mix them in the same request:
- noul: a yes/no judgment; returns the probability that the answer is yes.
- choice: picks one option from a set you define; returns the chosen option and the full probability distribution.
- score: rates along a rubric you define; returns a probability-weighted value across the levels.
- box: locates one target in an image and returns its bounding box coordinates.
Use application/json for text and structured data. To upload images, use multipart/form-data, with the JSON parameters in a request part and each image in a separate file part.
Request Headers
Authorization string *
Bearer Token authentication, in the form Bearer $ZENMUX_API_KEY.
Content-Type string *
Use application/json for text requests and multipart/form-data; boundary=... for image uploads.
Request Parameters
Send these parameters directly in a JSON request body to evaluate text or structured data. To upload images, select multipart/form-data.
model string *
The model ID to use, in the format <provider>/<model-name>, for example typesafe/jev-latest.
state string, object, or array *
The content to evaluate. It can be plain text (string) or structured data (object / array), such as a chat log, a business record, or the current state of your application.
questions object *
A non-empty map of typed questions. You choose each key, and the returned answers come back under the same keys. The keys are not sent to the underlying model and are not used in inference.
questions.<question-id> object *
A typed question object. Use type to select the question type and instructions to describe the task. The requirements for criteria depend on the type.
type string *
The question type, one of noul, choice, score, or box.
instructions string, object, or array *
What the model should decide for this question.
criteria object or array depends on type
The evaluation criteria, whose shape depends on type:
noul(optional): anobjectdescribing what a yes and a no mean viatrue/false.choice(required): anobjectmapping each option to its rubric description; usenullwhen an option needs no extra detail.score(required): an orderedarraydescribing the levels in order; include at least two levels.box: does not usecriteria.
Response
Returns a JSON object containing the structured answers.
model string
The model that performed the evaluation.
answers object
A map of answers, keyed by the same keys used in the request questions, with one answer per question.
answers.<question-id> object
The answer object whose type matches its question. The confidence (0 to 1) for choice and score is derived from the answer's probability distribution. Box confidence describes how certain the model is about the location.
- noul answer
typestring— alwaysnoul.noulnumber— the yes/no answer on a scale from 0 (no) to 1 (yes).
- choice answer
typestring— alwayschoice.choicestring— the highest-probability option.probabilitiesobject— every option mapped to its probability (floats that sum to 1).confidencenumber— how certain the model is, derived from the probabilities.
- score answer
typestring— alwaysscore.scorenumber— the probability-weighted value across the levels; can land between levels.legendobject— each level number mapped back to its description.probabilitiesobject— each level (string key) mapped to its probability (floats that sum to 1).confidencenumber— how certain the model is, derived from the probabilities.
- box answer
typestring— alwaysbox.boxobject— containstop,bottom,left, andright, each a normalized coordinate from 0 to 1.confidencenumber | null— confidence in the location, from 0 to 1;nullwhen the model does not provide it.
Coordinates start at the top-left corner. top and bottom are fractions of image height; left and right are fractions of image width. To convert to pixels, multiply horizontal coordinates by the width and vertical coordinates by the height.
Each Box question returns one box. Box returns coordinates even when the target is absent; there is no dedicated "not found" result. Ask a companion Noul question to check whether the target is present, and ignore the box when that probability is low. A returned box alone does not establish that the target exists. Tune confidence thresholds on your own images.
usage object
Token usage for this request.
input_tokensinteger— the number of tokens consumed by the input.output_tokensinteger— the number of tokens consumed by the output.
Image usage is included in input_tokens. Refer to the model's pricing in the ZenMux model catalog.
Examples
The examples cover JSON text requests and image uploads. The image example follows TypeSafe's request + file part structure and asks both Noul and Box questions. Prepare a photo.png containing a red rectangle within the image limits above, and set the ZENMUX_API_KEY environment variable. The TypeScript image example uses fetch, FormData, and Blob in Node.js 20+; Python uses requests. Response values are illustrative and will vary.
curl /api/v1/systemone \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ZENMUX_API_KEY" \
-d '{
"model": "typesafe/jev-latest",
"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"
}
},
"frustration": {
"type": "score",
"instructions": "How frustrated is the customer?",
"criteria": ["Calm", "Frustrated", "Very angry"]
}
}
}'import requests
resp = requests.post(
"/api/v1/systemone",
headers={
"Authorization": "Bearer <your_ZENMUX_API_KEY>",
"Content-Type": "application/json",
},
json={
"model": "typesafe/jev-latest",
"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",
},
},
"frustration": {
"type": "score",
"instructions": "How frustrated is the customer?",
"criteria": ["Calm", "Frustrated", "Very angry"],
},
},
},
)
print(resp.json())const resp = await fetch("/api/v1/systemone", {
method: "POST",
headers: {
Authorization: "Bearer <ZENMUX_API_KEY>",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "typesafe/jev-latest",
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",
},
},
frustration: {
type: "score",
instructions: "How frustrated is the customer?",
criteria: ["Calm", "Frustrated", "Very angry"],
},
},
}),
});
console.log(await resp.json());{
"model": "typesafe/jev-latest",
"answers": {
"is_urgent": {
"type": "noul",
"noul": 0.92
},
"department": {
"type": "choice",
"choice": "technical",
"probabilities": { "billing": 0.08, "technical": 0.85, "sales": 0.07 },
"confidence": 0.82
},
"frustration": {
"type": "score",
"score": 1.6,
"legend": { "0": "Calm", "1": "Frustrated", "2": "Very angry" },
"probabilities": { "0": 0.05, "1": 0.3, "2": 0.65 },
"confidence": 0.78
}
},
"usage": { "input_tokens": 312, "output_tokens": 48 }
}curl /api/v1/systemone \
-H "Authorization: Bearer $ZENMUX_API_KEY" \
-F 'request={
"model": "typesafe/jev-1.14",
"state": {
"photo": "0b719304-319a-4f83-a84e-55a9fb3e16b8"
},
"assets": {
"0b719304-319a-4f83-a84e-55a9fb3e16b8": {
"type": "image",
"part": "photo-file"
}
},
"questions": {
"has_red_rectangle": {
"type": "noul",
"instructions": "Does the image in `photo` contain a red rectangle?"
},
"red_rectangle_location": {
"type": "box",
"instructions": "the red rectangle in `photo`"
}
}
};type=application/json' \
-F '[email protected];type=image/png'import json
import os
import requests
body = {
"model": "typesafe/jev-1.14",
"state": {
"photo": "0b719304-319a-4f83-a84e-55a9fb3e16b8"
},
"assets": {
"0b719304-319a-4f83-a84e-55a9fb3e16b8": {
"type": "image",
"part": "photo-file"
}
},
"questions": {
"has_red_rectangle": {
"type": "noul",
"instructions": "Does the image in `photo` contain a red rectangle?"
},
"red_rectangle_location": {
"type": "box",
"instructions": "the red rectangle in `photo`"
}
}
}
with open("photo.png", "rb") as image:
resp = requests.post(
"/api/v1/systemone",
headers={"Authorization": f"Bearer {os.environ['ZENMUX_API_KEY']}"},
files=[
("request", (None, json.dumps(body), "application/json")),
("photo-file", ("photo.png", image, "image/png")),
],
timeout=60,
)
resp.raise_for_status()
print(resp.json())import { readFile } from "node:fs/promises";
const body = {
"model": "typesafe/jev-1.14",
"state": {
"photo": "0b719304-319a-4f83-a84e-55a9fb3e16b8"
},
"assets": {
"0b719304-319a-4f83-a84e-55a9fb3e16b8": {
"type": "image",
"part": "photo-file"
}
},
"questions": {
"has_red_rectangle": {
"type": "noul",
"instructions": "Does the image in `photo` contain a red rectangle?"
},
"red_rectangle_location": {
"type": "box",
"instructions": "the red rectangle in `photo`"
}
}
};
const form = new FormData();
form.append(
"request",
new Blob([JSON.stringify(body)], { type: "application/json" }),
"request.json",
);
form.append(
"photo-file",
new Blob([await readFile("photo.png")], { type: "image/png" }),
"photo.png",
);
const resp = await fetch("/api/v1/systemone", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.ZENMUX_API_KEY}` },
body: form,
});
if (!resp.ok) {
throw new Error(`HTTP ${resp.status}: ${await resp.text()}`);
}
console.log(await resp.json());{
"model": "typesafe/jev-1.14",
"answers": {
"has_red_rectangle": {
"type": "noul",
"noul": 0.98
},
"red_rectangle_location": {
"type": "box",
"box": {
"top": 0.26,
"bottom": 0.74,
"left": 0.22,
"right": 0.78
},
"confidence": 0.94
}
},
"usage": {
"input_tokens": 1162,
"output_tokens": 40
}
}