APIs and capabilities
TypeSafe API Guide
Use the Jev System One API for decisions, classification, scoring, image recognition and Box localization, with cURL, Python and Node.js examples.
Jev evaluates text, structured data and images for moderation, ticket classification, scoring and object localization. Put your content in state and your questions in questions to receive structured answers.
Gateway endpoint: POST https://api.zhenapi.ai/v1/systemone. Send a nonstreaming JSON request and receive a complete JSON response. No messages, prompt or stream parameter is needed.
1. Create a key and choose a model
Open the API Keys page and create or select a key in a TypeSafe group. Set the following environment variable in the terminal running your script. Keep real keys out of Git and browser-side code.
| Model ID | Gateway recommendation | Images / Box |
|---|---|---|
jev-latest | Currently maps to jev-1.14.0 on this gateway; the mapping may change. | Depends on the currently mapped model. |
jev-1.14.0 | Use for a fixed version or Box support. | Images and Box supported. |
jev-1.13.0 | Keep the older model behavior, with long context support. | Images supported; Box not supported. |
Model aliases follow gateway settings and may differ from the official service. For reproducibility, use a full model version and record the returned model. Examples use English questions and criteria. Validate behavior against your own data.
Request fields and four question types
model, state, questions are required. state can be a string, object or array. questions must be a nonempty object with one key per question. Write the actual question in instructions; question IDs only identify results. For images, include top-level assets.
| type | Purpose | criteria format | Reading the result |
|---|---|---|---|
noul | Yes/no decisions, moderation and content checks | Optional; true / false entries can describe the decision criteria. | noul is a probability from 0 to 1, not a boolean. A value near 0.5 indicates uncertainty. |
choice | Classification, routing and selecting one option | Object mapping option IDs to descriptions; 1–255 options. | choice is the selected option ID. The response also includes confidence and probabilities for all options. |
score | Rating, ranking and prioritization | Ordered array with 1–10 levels, indexed from 0. | score is the probability-weighted average of the levels and may be fractional. The response also includes confidence, legend and probabilities. |
box | Locate one specified object in an image | No criteria required. Describe the target and image in instructions. Supported only by 1.14.0. | box contains left / top / right / bottom. confidence may be null. Each question returns one box. |
Multiple questions can share the same state in one request. If a later step needs an earlier answer, issue a new request from your application. Confidence and probability are different metrics; validate your own decision thresholds.
2. Text: decisions, classification and scoring in one request
The example asks three questions about one refund message. Keys in questions are your result IDs; answers uses the same keys. Questions are evaluated independently and cannot reference answers to other questions in the same request.
The cURL example uses Bash / WSL. The Python 3 example uses only the standard library: save it as typesafe.py and run python3 typesafe.py (or py typesafe.py on Windows). Node.js 18+ needs no extra packages. Set the environment variable above, then run examples in the same terminal.
3. Image input and Box localization
Place an image.png containing a red rectangle in the working directory. The example encodes it as Base64, references it in state.photo with a random UUID, and asks both whether the object exists and where it is. Both models support image input; the Box example uses jev-1.14.0.
For image decisions or classification only, remove the target Box question and use jev-1.13.0 if desired. For JPEG, update both the filename and format to jpg / jpeg. The 0.8 threshold is illustrative; validate a threshold against your own samples.
Preparing and sending images
- Only static PNG / JPEG images are supported. Width and height must each be 280–1568 pixels. Resize or pad images as needed, and correct their orientation before encoding.
- The official limits are 16 MiB per image file and 32 MiB per request body. Processed images and expanded references have additional limits. The gateway may enforce a smaller limit.
data_base64must be plain Base64 without a data:image/... prefix or line breaks.formatmust be lowercase png, jpg or jpeg.- Give each image a unique UUID in assets and reference it from a value in state, instructions or criteria. An unreferenced asset fails validation. Repeated references increase expanded input size. Put a shared image reference in state only once.
- This gateway uses JSON + Base64. Official multipart uploads, automatic SDK image uploads and compressed bodies cannot be used directly. Image URLs are not downloaded automatically; read the image bytes first.
Using Box coordinates
Coordinates range from 0 to 1, with the origin at the top-left corner. For a submitted image of width W and height H: x1 = left × W, y1 = top × H, x2 = right × W, y2 = bottom × H. Round and clamp coordinates to the image bounds before cropping. If you resized or cropped the input, convert the coordinates back to the original image.
4. Long context: read a local file
Save UTF-8 text as document.txt. This example uses jev-1.13.0 to check whether a contract allows early termination; jev-1.14.0 also works. The file contents are sent as state. The model does not automatically read a URL or local path.
Long context is enabled by default: both the whole request and state plus one question are limited to 262K tokens, with unchanged pricing for both models. A local gateway test succeeded with 130,331 input tokens on 1.13.0; the full 262K limit has not been tested. Input includes state, questions and images, not just file characters. Split oversized input into multiple requests.
5. Usage and billing
The response field usage.input_tokens includes input usage for text, questions and images; usage.output_tokens reports output usage. Billing is currently based on input tokens, with free output. Images have no separate surcharge, and long context does not increase the per-token rate.
Cost is input tokens divided by 1,000,000, multiplied by the effective input rate for your group. See TypeSafe on the pricing page for rates and multipliers, and your usage records for actual charges. Do not use rounded display prices for precise billing reconciliation.
6. Troubleshooting
| Symptom | What to check |
|---|---|
| 401 / 403 | Use a valid, complete ZhenAPI key assigned to a TypeSafe group. A key from the official TypeSafe console cannot replace your gateway key. |
| 404 / unsupported protocol | Use /v1/systemone. These models do not use /v1/chat/completions, /v1/responses or /v1/messages. The OpenAI mode of a chat client is not a direct substitute. |
| 400 / 422 | Check model, state, questions and criteria against the returned error. Use lowercase field names and a nonempty questions object; do not set stream=true. For images, also check format, dimensions, Base64 encoding and references. |
| max_tokens_exceeded | Text, questions and images exceed the context limit. Use fewer images or repeated references, shorten questions, or split the text across requests. |
| 413 | The body or image is too large. Base64 is typically about one third larger than the original image. Resize images, reduce repeated references or split requests. The lower of the gateway and upstream limits applies. |
| 429 / 503 / model_not_found | Reduce concurrency and retry with backoff, following Retry-After when present. For unavailable models or channels, check the full model ID and group. Contact support if failures persist. |
Official references
Based on the official TypeSafe documentation and this gateway integration. Last checked: 2026-10-17.