Fresh snow over the loading yard, criss-crossed with tonight's sleigh tracks. A child asked for a train set and got a cheerful reply about ponies, and nobody knows which call sent it.
- Sprocket
We answered a train-set letter with ponies! I'll add a
print()to every function and redeploy. - Ledger
Hundreds of replies tonight and one of them is a pony. I want the call, the model and the tokens, counted like candy canes. Not
print()lines. - Sprocket
Then I'll scroll the dashboard. It's only hundreds. I'll be done by Boxing Day!
- Tinsel
Leave the code alone. Every routed call already left tracks:
orq traces searchfinds tonight's,orq traces convreads the pony one.
- clientYour appPOST /v3/router
- requestorq.aiAI Routerrules · guardrails · model
- recordstraceTrace and spansmodel · tokens · cost · ms
- readscliorq tracessearch · conv · get-batch
- printsreaderYou or your agent-o json
How it works
Tinsel’s fix needs no redeploy: the router has been keeping notes on every call all night.
- Trace. Every call through the AI Router is recorded as a trace. It holds a timeline of steps, from routing decisions to the model call, with model, provider, tokens, cost, status and duration.
- Search.
orq traces searchlists the traces in a time window. It callsPOST /v3/traces/search, and every field of that body is a flag:--from,--to,--query,--filters,--limit. - Read.
orq traces conversation(aliasconv) turns one trace into a list of messages, tool calls and reasoning. Chat Completions, Responses and OpenTelemetry GenAI payloads all come out in the same shape. (The CLI docs page shows it asorq traces thread, which runs the same command.) - Script.
-o jsonprints the API response as JSON on stdout. That is the stable contract, so a shell script, a CI job or a coding agent can read the same traces you do.
Run it
Install the CLI and sign in:
curl -fsSL https://cli.orq.ai/install.sh | sh
orq auth login
Make a trace by sending one request through the router:
curl https://my.orq.ai/v3/router/chat/completions \
-H "Authorization: Bearer $ORQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-6-luna",
"messages": [
{"role": "user", "content": "Name three reindeer."}
]
}'
The trace lands in the project of the key you sent it with; search that project, or pass --project.
Find it, then read it:
orq traces search --from 1h --to now --limit 20 -o json \
-j 'data[].{id: trace_id, models: models, status: status}'
orq traces conv <trace_id> --spans
orq traces conv <trace_id> --slice -4: -x reasoning
-j takes a JMESPath expression, so you print only the fields you need. Each search result carries trace_id, status, models, providers, usage, cost and duration_ms.
Narrow it down
| You want | Add this |
|---|---|
| Only failed calls | --filters with status in ["error"] |
| The fields you can filter on | orq traces list-fields |
| The last four messages | orq traces conv <id> --slice -4: |
| Messages that mention a word | orq traces conv <id> --match pony |
| The turns without the thinking | orq traces conv <id> -x reasoning |
A filter entry is {"field", "op", "values"}. Operators include eq, in, gt, between, contains and exists. Values are always strings, even for numbers and timestamps.
To fetch many traces in one process, pipe the ids in:
orq traces search --from 1h --to now -o json \
-j 'data[].trace_id' --raw | orq traces get-batch -o json
The output is an array in input order, one entry per id, with an error field on any id that could not be read.
Gotchas
Time. Without --from and --to, search covers the last 7 days. Relative values count back from now. Bare dates are read as UTC.
Which workspace. An exported ORQ_API_KEY wins over your browser login. If search answers 401 or shows another project’s traces, unset ORQ_API_KEY and try again. The CLI prints Using ORQ_API_KEY from environment on stderr when this happens, and orq doctor shows which credential is in use. Traces belong to a project; --project picks a different one.
Long messages. The xml and markdown renders of conv cut each block at 4,000 characters by default; -o json, yaml and toon stay uncut unless you pass a cap. Pass --max-chars 0 for everything. conv also refuses -o table: use the default XML, markdown, json, yaml or toon.
Nice list
- Set the window with
--fromand--to. Durations like30m,24hor7dcount back from now, and bare dates are read as UTC. - Run
orq traces conv <trace_id> --spansfirst. It shows which span the command reads and marks it with*. - Pipe ids into
orq traces get-batchinstead of looping overorq traces get. A failing id does not abort the batch. - Use
orq traces conv <trace_id> -o markdownto paste a conversation into a ticket or chat.
Naughty list
- Leaving an old
ORQ_API_KEYexported. It beats your browser login and brings the key's own project restrictions, so you search the wrong project or get a401. - Trusting a long tool result in the default
convrender to be whole. The xml and markdown renders cut each block at 4,000 characters; pass--max-chars 0to see everything. - Sprinkling
print()through every function and redeploying to find one bad reply. The router already traced that call, with model, tokens and cost.
Elf's challenge
The pony was a bad answer, not an error. Ledger still wants every call that errored in the last 24 hours. Write the one orq traces search that lists them, and say how many filters it can hold.
Stuck? Ask Tinsel for a hint
Run orq traces search --from 24h --to now --filters '[{"field":"status","op":"in","values":["error"]}]'. One search holds up to 20 filters, combined with and unless you pass --filter-operator or.
Christmas crackerWhy did the night-shift elves' script choke on the workshop carols?Pull it for the punchline
Piped, the CLI sings in TOON. Scripts want -o json.