Intent routing
A router decides where a message goes. A prompt-based router returns prose that you parse, and it drifts when you edit the wording. Classify returns one label name, a probability for that label, a score for every route, and a confidence number. One call takes about one second.
Use this pattern in front of a tool set, an agent hand-off, or a work queue. Use the OpenAI-compatible surface instead when your caller already speaks the OpenAI chat API.
The shape
Name one label per route
One label per destination. Add a description that states which cases belong to it. See writing good statements and labels.
Add a fallback label
Give the router somewhere to put a message that fits nothing. Without it the model must pick a wrong route.
Route a support message
The object form of labels maps each route name to its description. The model reads "name: description", so both parts carry weight.
The response, captured live in 1.15 s:
scores sums to 1 over the label names. The runner-up here is other at 0.321, and confidence 0.522 reports that spread. The winner is right, but the router is not certain.
Dispatch on the numbers
Pick one band per route, not one band for the router. A read-only lookup can act at 0.5. A refund or a cancellation should ask first. Thresholds and confidence routing covers the method.
Show the top two entries of scores when you ask the user. “Billing, or something else?” is a better question than “What do you need?”.
The numbers above are examples, not product defaults. Measure your own bars against a labelled set. Tuning thresholds turns that set into a number per route.
Route over the OpenAI surface
Send your existing tools array to https://api.milliseconds.ai/v1. The API classifies the text over the tool descriptions, picks one tool, then fills its parameters schema with extract. Exactly one tool call comes back, with finish_reason: "tool_calls".
The captured reply, 1.33 s:
A field the text does not support comes back as null. Treat a null argument as a missing slot and ask for it.
The tool name joins its description in the label text. The same two tools with the first one named open_billing_case routed this message to track_order in a live call. Name tools after the case they handle, not after the action they perform.
Four rules govern this path. The API uses a single tool in the array directly, with no classify call. A classify winner that names no tool in the array falls back to the first tool. tool_choice: {"type":"function","function":{"name":"..."}} forces that tool and skips the routing step. tool_choice: "none" turns the tools path off, so the request needs response_format.json_schema or it returns 400 unsupported_request.
Native or OpenAI
The OpenAI surface returns no probability and no scores, so you cannot set a confidence band on it. When to use the native API lists the full trade.
Route a backlog
texts classifies up to 32 messages in one request. The response is {"results":[...]} in input order, so you can zip it against your queue. Each text costs one inference call. The calls spread across the inference slots, so a large batch takes longer than a single message. Batching covers the ordering and the limits.
Next
- Classify documents every field this pattern reads.
- Thresholds and confidence routing sets the per-route bars.
- Taxonomy classification walks a deep route tree level by level.