Docs
CommunityJev Cookbooks
Gate Agent Tool Calls with Jev
An OpenRouter cookbook recipe that replaces a blanket human-approval rule with a per-call Jev check: the proposed tool call, ticket, and policy go to Jev, whose probabilities route to approve, block, or review.
- Format
- Docs
- Reading time
- 2 min
- Published by
- Community
- Last verified
- Oct 2026
- Languages
- TypeScript
- Platforms
- OpenRouterAPI
- Capabilities
- Requires API key
Highlights
- Jev is on OpenRouter as typesafe/jev-1.13 through the Decisions endpoint, so the agent model and the gate share one API key.
- gateRefund runs two deterministic order checks, then asks Jev three yes-or-no questions about the refund, ticket, and policy.
- Thresholds route the result: run on approve, refuse on block, and pause with status: 'awaiting_hitl' on review.
- The client posts to https://openrouter.ai/api/alpha/decisions and validates the reply with zod, throwing on bad probabilities.
- The recipe reports one Decisions request per call at under $0.0001 in its runs, and each decision includes a reason for the audit log.
Watch out
Grounded in the truncated cookbook capture from 2026-10-15; only the setup and the start of the request client are visible, the full gateRefund implementation, fixtures, and test harness were cut off, and the sub-$0.0001 cost is the page's own figure.
Questions about this entry
Short answers drawn from the linked project or page.
A per-call gate for a risky tool: instead of pausing every call for human approval, it sends the proposed call, the ticket, and your policy to Jev and routes on the returned probabilities.
typesafe/jev-1.13 on OpenRouter, through the Decisions endpoint, so the same OPENROUTER_API_KEY that runs the agent model also runs the check.
Approve, block, or review. The tool runs only on approve, the model receives a refusal with a reason on block, and the loop pauses with status: 'awaiting_hitl' on review.
Jev receives the state and three yes-or-no questions; fixed thresholds turn each probability into a decision. The recipe's example asks about the proposed refund against the ticket and policy text.
The page says static rules check one thing, like the tool name or a condition on arguments, but the same refund tool can be safe in one call and not the next, and the difference lives in the ticket, which Jev can read.
An existing TypeScript agent using @openrouter/agent with a HITL tool, zod 4, @types/node or @types/bun, an OPENROUTER_API_KEY, and a StateAccessor for conversation state.
No. The recipe stresses that Jev returns a probability per question rather than prose, so the gate is a few numeric comparisons your code controls, with reasons kept for the audit log.
From the Jev guides
Original write-ups on what this entry is for.
From the Jev AI model community
Posts from builders shipping with Jev right now.