Credentials. Store the TypeSafe API key in an environment variable or secret manager and never commit it to code or logs.
Who it is forA backend developer whose app sends every request to one expensive model and needs cheaper routing for easy tasks.
The problemSending all tasks to the strongest model raises cost, while a naive router can send hard tasks to a weak model without any signal.
The outcomeA routing function that returns a model tier per request, escalates when confidence is low, and is checked against a labeled set.
What you need first
- A TypeSafe AI API key from the official docs, if you call the API directly
- Python or Node.js, if you use the SDKs or framework adapters
- A labeled set of example inputs to test Jev decisions before relying on them
Steps
- Read the 手把手 Jev guide in docs/HANDS_ON.md for state design, low-confidence fallback, and validation set steps.
- Install the Python SDK with
pip install typesafe-sdk, or use the JS/TS package@typesafe-ai/sdk. (inferred, check the README) - Define a Choice question with options such as cheap, strong, and escalate, and send a text state to
POST https://api.typesafe.ai/v1/systemone. - Escalate to the strong model when the returned confidence is below your threshold, and log each decision.
- Run the router on a labeled set of past tasks and compare routed results with the strong model's results before deploying.
Prompt for your agent
Using the Promethe-us/awesome-jev README and docs/HANDS_ON.md, draft a routing function for <my task type> that sends each request to a cheap or strong model using a Jev Choice decision. Return the code and the confidence threshold you chose, then verify on a labeled set that escalation happens on hard cases.
Caveat. Jev returns typed decisions with probabilities, but a typed output can still pick the wrong option, so the router needs a labeled validation set before it controls real traffic.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for Promethe-us/awesome-jev and "Route simple and hard tasks to different models"
Add Deduped to Claude Code once
claude mcp add --transport http deduped https://dedupedai.com/mcp
Every Monday: the 5 hottest repos and exactly how to use them. Free, one email a week, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer