Patterns
A capability returns one decision. A pattern turns that decision into behaviour in your code.
Each page below states the problem, the wiring, and the numbers you branch on. Every page carries curl, Python and TypeScript.
Pick a pattern by the problem
The patterns
Read probability and confidence as two axes. Raise the bar with the blast radius of the action.
Screen every message into and out of an LLM app: jailbreak, harmful request, self-harm, medical advice, urgency.
Extract a record, then check each critical field against the source text before you write it.
Answer the easy cases with one decision call. Send only the uncertain ones to a large model.
Split a broad judgment into several rate calls. Weight them in your own code.
Classify the user turn over described labels, then dispatch to a tool, an agent, or a queue.
What every pattern assumes
Three facts drive all six patterns.
- A decision returns a number, not prose. You branch on
probabilityorconfidenceinstead of parsing text, as decisions and probabilities describes. - A batch costs one HTTP request.
textstakes up to 32 inputs, but each text is a separate model call.statementsandquestionsbatch inside one text in one inference call, and each adds only its own length to the billed input, under batching. - The thresholds are yours. The API never decides for you what is confident enough. Pick the bands on thresholds and confidence routing.
Every code sample on these pages runs without credentials. No API key is required during the launch period.
Patterns and recipes
A pattern is a shape you apply to your own problem. A recipe is a finished job with a schema, labels, and thresholds already chosen. A recipe combines the patterns above.
Next
- Confidence routing is the base that the other five build on.
- Thresholds and confidence routing explains the bands before you write code.
- Recipes applies these patterns to concrete jobs.