Recipe catalog / route-many
Route many requests in batches
route-many is a Jev recipe from the jev-recipes TypeScript package. Which named route handles each of up to 500 requests, judged in batched Jev requests so a queue of tickets, emails, or events is routed in a handful of calls instead of one per item? Use it when you have a backlog or stream of messages to route to the same set of handlers and want batched throughput with a per-item review outcome.
Last updated .
Explore this recipe interactively · Source and implementation guide · Markdown version
How do I use route-many in TypeScript?
Install with npm install jev-recipes. Requires Node.js 22.9 or newer and ES modules. Set TYPESAFE_API_KEY in your server environment for live calls, which send input to TypeSafe and use API quota. See the installation guide.
import { routeMany } from 'jev-recipes/route-many';
const result = await routeMany({
"requests": [
{
"id": "t-1041",
"text": "I was charged twice for my subscription this month. Please refund one of the charges."
},
{
"id": "t-1042",
"text": "The export button on the reports page does nothing when clicked. Console shows a 500 error."
},
{
"id": "t-1043",
"text": "Can I get a demo of the enterprise plan for a team of 40?"
},
{
"id": "t-1044",
"text": "hi"
}
],
"routes": {
"billing": "Payments, invoices, subscriptions, and refunds",
"technical": "Errors, outages, and broken product features",
"sales": "Pricing questions, plan upgrades, demos, and new purchases"
},
"batchSize": 20,
"minConfidence": 0.8
});
console.log(result);
What input does route-many take?
| Field | Type | Needed |
|---|---|---|
| requests | array | Required |
| routes | object | Required |
| batchSize | integer | Optional |
| minConfidence | number | Optional |
Full input and result schemas
{
"input": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"requests": {
"minItems": 1,
"maxItems": 500,
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"text": {
"type": "string"
}
},
"required": [
"id",
"text"
]
}
},
"routes": {
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"type": "string"
}
},
"batchSize": {
"type": "integer",
"minimum": 1,
"maximum": 50
},
"minConfidence": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"required": [
"requests",
"routes"
]
},
"result": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"model": {
"type": "string"
},
"usage": {
"type": "object",
"properties": {
"input_tokens": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"output_tokens": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"input_tokens",
"output_tokens"
],
"additionalProperties": false
},
"status": {
"type": "string",
"enum": [
"ready",
"review"
]
},
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"status": {
"type": "string",
"enum": [
"ready",
"review"
]
},
"route": {
"type": [
"string",
"null"
]
},
"suggestedRoute": {
"type": [
"string",
"null"
]
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"probabilities": {
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"type": "number",
"minimum": 0,
"maximum": 1
}
}
},
"required": [
"id",
"status",
"route",
"suggestedRoute",
"confidence",
"probabilities"
],
"additionalProperties": false
}
},
"routed": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"requestCount": {
"type": "integer",
"exclusiveMinimum": 0,
"maximum": 9007199254740991
},
"requestsMade": {
"type": "integer",
"exclusiveMinimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"model",
"usage",
"status",
"items",
"routed",
"requestCount",
"requestsMade"
],
"additionalProperties": false
}
}What does a route-many result look like?
This hand-authored response demonstrates the contract. It is not a model accuracy measurement. Run it without an API key: npx jev-recipes demo route-many.
{
"model": "demo-fixture",
"usage": {
"input_tokens": 0,
"output_tokens": 0
},
"status": "review",
"items": [
{
"id": "t-1041",
"status": "ready",
"route": "billing",
"suggestedRoute": "billing",
"confidence": 0.95,
"probabilities": {
"billing": 0.95,
"technical": 0.01,
"sales": 0.01,
"__review__": 0.03
}
},
{
"id": "t-1042",
"status": "ready",
"route": "technical",
"suggestedRoute": "technical",
"confidence": 0.94,
"probabilities": {
"billing": 0.01,
"technical": 0.94,
"sales": 0.01,
"__review__": 0.04
}
},
{
"id": "t-1043",
"status": "ready",
"route": "sales",
"suggestedRoute": "sales",
"confidence": 0.93,
"probabilities": {
"billing": 0.02,
"technical": 0.01,
"sales": 0.93,
"__review__": 0.04
}
},
{
"id": "t-1044",
"status": "review",
"route": null,
"suggestedRoute": null,
"confidence": 0.85,
"probabilities": {
"billing": 0.05,
"technical": 0.05,
"sales": 0.05,
"__review__": 0.85
}
}
],
"routed": 3,
"requestCount": 4,
"requestsMade": 1
}
Input
See shared options and behavior for client configuration, validation, and errors. Types are inferred from this folder's Zod 4 schemas.
requests holds up to 500 items with unique ids. routes maps route names to descriptions, exactly as in route. batchSize sets how many requests share one Jev call, from 1 to 50, defaulting to 20. Batches run concurrently.
Result
items has one entry per request, in input order, with the same fields as a route result: status, route, suggestedRoute, confidence, and probabilities. routed counts the items that received a ready route. requestCount is the number of inputs and requestsMade the number of Jev calls, so you can see the batching ratio.
The result status is review when any item is review. Items are independent, so a caller can act on the ready ones and queue the rest.
usage sums tokens across all calls. model comes from the first response.
Reuse and calls
Uses the shared batch runner to split requests into chunks and merge the results. One live invocation makes ceil(requests / batchSize) Jev requests, each carrying one routing question per request in that chunk. This folder owns the routing instruction, the review policy, and the aggregation.
Limits
Smaller batches cost more calls and larger batches risk lower per-item accuracy. Start at the default, measure against labeled data, and adjust batchSize per workload.
If one batch fails, the whole call rejects. Retry at the caller level, or split the input and call the recipe per group when partial results matter.
Example input
demo.json contains editable input and a hand-authored response. After installing jev-recipes, npx jev-recipes demo route-many shows an offline illustration, not an accuracy measurement. Use npx jev-recipes describe route-many to inspect the input and result schemas.
Build a conversation
Use this recipe for independent requests, not consecutive turns in one conversation. For questions that gather missing details before routing, see the support conversation starter.
How accurate is route-many?
jev-1.13.0 / 2026-10-04 / 87 development cases
Scoring revision 2.
47 ready decisions, with 98% accuracy among those decisions.
95% case-level interval: 87% to 98%. Related synthetic cases are correlated.
This measures the recorded dataset, not general readiness. Label sources: unspecified: Existing repository labels; independent review and original authorship were not recorded.; author-synthetic: AI-authored synthetic boundary cases for jev-recipes; labels have not had independent human review.
Use the evaluation guide to measure this decision on your own labeled cases.
What are the limits of route-many?
- Every request in a batch shares one model call, so accuracy can fall as batches grow; the default batch size of 20 is a starting point to tune against your own labels.
- Per-item results are independent judgments. The recipe does not deduplicate or group related requests.
Which recipes are related to route-many?
- route: Use route for a single request, or when each request has its own set of routes.
- ticket-match: Use ticket-match to link a new message to an existing ticket rather than a queue.