Taxonomy classification
Walk a support taxonomy with one classify-tree call, then read the per-level numbers before you act.
A taxonomy is a tree of labels. The support taxonomy below has four top-level areas and four leaves under each of the first two. One flat classify call puts every leaf against every other leaf, so leaves from far-apart branches steal probability from each other.
Walk the tree instead. Classify tree does the walk in one request. Each
level is one classify call over the children of the winner from the level above, and the response
returns every level.
Try flat first. The array form of labels accepts 2 to 64 labels. The object form carries no documented count cap. The cost of a classify call does not change with the label count. If every leaf fits in one call and the leaf descriptions do not overlap, send them all at once.
The taxonomy
Give every label a description. The model reads "name: description" when a description exists, and a
bare name otherwise. Descriptions improve accuracy, as
Writing good statements and labels shows. A string value is a leaf.
An object value carries its own labels.
Every level needs 2 to 64 labels, and the tree holds at most 8 levels. A level with one label returns
{"error":{"code":"invalid_request","message":"tree.billing.labels: each level needs 2 to 64 labels"}}.
A clean descent
Send the text and the whole tree. The API picks the branch, then picks the leaf inside that branch.
The walk returns billing > subscription_change. Level 1 confidence 0.607 clears the 0.60 bar in the
code below. Level 2 confidence 0.553 clears the 0.45 bar. The compound probability of 0.624 is the
product of 0.766 and 0.814, so it sits below both levels. Threshold the level you act on.
That call reported x-input-chars: 885 and x-input-tokens: 216: the size of the request body, counted
once. x-inference-ms is the sum over the two levels.
When confidence drops
This ticket is clear at level 1 and ambiguous at level 2:
I was charged twice for my annual subscription on 3 March and the second charge has not been refunded.
Two leaves tie at 0.434 and level 2 confidence reports 0.285. The ticket describes a duplicate charge
and a refund request. Stop at billing and send the leaf choice to a person. The API returns the tie
winner anyway, so your code must read levels and drop the leaf itself.
Never read label alone on a deep walk. The winner at a tie is still a single name, and a wrong level-1 branch makes every level below it wrong. Leaves inside one branch describe close cases, so expect lower confidence deeper in the tree. Set a threshold per level, not one threshold for the whole tree.
classify-tree bills the request body once, whatever the depth. A client-side walk is a separate call per level, so it re-sends the full text each time. A three-level client walk makes three calls and sends the text three times, so it costs three times as much. You pay $0.04 per million input tokens and $0 per output token. See Pricing. One classify call took 0.43 s end to end in our measurement, so budget the depth.
Walk it yourself when you need a stop rule per level
classify-tree always walks to a leaf. It returns every level, so you can apply thresholds after the
call and keep a partial path. A client-side walk goes further: it never runs the calls below a level
you would reject. Pick it when you want to stop early. It costs more, because every level is its own
billed call.
A node with one child needs no call. The walk appends that child and moves down. classify-tree rejects a level with one
label, and so does the array form of labels on classify. The object form does not, so skip the
call yourself.
Tune the thresholds
Pick the numbers per level from real data, not from a guess.
Build a golden set of 50 to 200 real tickets with the full path labelled. Then score each level on its own and tune the thresholds per level.