New: Cookbooks and AI ExplanationsStep-by-Step recipes to solve problems connected to Roadmaps and Cheat Sheets. Need more details? Use AI buttons for structured and simple explanations with concrete examples throughout the whole platform.Take a look
The router keeps inventing categories I never gave it.
What you'll have at the end
A script that classifies 20 sample tickets and never returns a label outside the allowed set
You need
A working call to an LLM chat API that already sends a prompt and reads back the reply, plus the exact short list of category names your router is allowed to use.
Not covered
Improving how well the model tells two similar-sounding categories apart, and writing one schema that satisfies more than one provider's API at once: this only stops it from ever answering with something off your list.
Resubmit a rejected reply with the schema error attached
the reply fails validation outright instead of quietly returning a value outside the enum, and you want the model to see the exact error and retry.
A safety refusal skips every field in your schema
a refusal is the failure you need to handle in depth, beyond the one guard clause here.
Write one JSON Schema that satisfies OpenAI and Claude's strict mode
the same router has to run the identical enum against more than one provider's API.
Checked 15 Aug 2026
Part of the Structured Output Generation with LLMs cookbook