AI & MCP
Classifying support tickets with a small model
Ticket classification is routing: fixed labels, a confidence threshold and a human queue. A small model is enough, and batch halves the price.
Key points
- Five to twelve labels with an owner each cover most tickets.
- A classification without confidence cannot be routed: below the threshold it goes to a human queue.
- Batch mode halves the price and accepts latency a ticket can afford.
Classifying tickets is a routing decision: fixed labels, a confidence threshold and a human queue for whatever stays ambiguous.
Labels before the model
- Few and stable: five to twelve labels cover most tickets, each with an owner.
- One extra label: "other" is a valid label and must be counted, not hidden.
- Examples per label: ten already-routed tickets are worth more than a long description.
import { generateText } from 'ai';
const labels = ['billing', 'bug', 'shipping', 'account', 'other'] as const;
const result = await generateText({
model: 'openai/gpt-5-nano',
system:
'Return one label from this list and nothing else: ' +
labels.join(', ') +
'. If none fits, return other.',
prompt: ticket.subject + '\n\n' + ticket.body,
maxOutputTokens: 8,
});
const label = result.text.trim().toLowerCase();
console.log(labels.some((l) => l === label) ? label : 'other');
console.log(result.usage);
Eight output tokens are enough for one word. If the model writes a sentence, the validator drops it and the ticket goes to the human queue: that is the correct behaviour, not an error to hide.
The threshold, not the label
A classification without confidence cannot be routed. Ask for a score from 0 to 1 as well, and send everything below 0.8 to a person: it costs less than one wrong billing ticket.
Batch pays half
A ticket is not as urgent as a chat: batch mode halves the price and accepts latency. With gpt-5-nano input drops to $0.025 per million, so the saving comes from volume, not from switching model.
The limitation
Quality depends on the examples, and this site has no labelled ticket set: no accuracy figure here is measured. A model trained on wrong labels learns the mistake as efficiently as it learns everything else.
Where to continue
How to evaluate a classifier is in evaluating an agent, instructions that hold up in prompt engineering for agents, cost per job in cost per task. The records: 111,985 components, 1,556 blocks, the 21st.dev sidebar.
Frequently asked questions
How many labels does ticket classification need?
Five to twelve in most cases. Beyond that the labels overlap and the person assigning them by hand stops agreeing with themselves.
Do I need a large model to label a ticket?
No. The task is short and the vocabulary closed, so a small model with eight output tokens is enough. Quality comes from the examples per label, not from model size.
How do I handle ambiguous tickets?
With a confidence threshold and a human queue. Anything below 0.8 is not routed automatically: the model proposes, a person decides, and the decision becomes an example.
What does it cost to classify ten thousand tickets?
It depends on tokens per ticket. With gpt-5-nano at $0.05 per million input tokens and $0.40 output, ten thousand tickets of 300 tokens cost $0.15 of input plus the output, and half that in batch.
Batch mode or single calls?
Batch when the ticket can wait a few hours, because it halves the price. Single calls when the ticket arrives in chat and the answer is needed at once.