Public API: Per-Message Cost and Tokens
If you drive Nairi from code, you can now see exactly what each turn costs and how many tokens the agent burned, straight from the message itself.
What's new
cost_usdon every assistant message — the total cost of the turn in US dollars, with 10-decimal precision.- Token breakdown —
input_tokens,output_tokens,cache_read_tokens, andcache_write_tokensso you can see where the cost went. model— the exact model identifier the agent used for that turn (e.g.claude-opus-4-7).- Returned on both message endpoints —
GET /api/public/v1/messages/{message_id}andGET /api/public/v1/conversations/{job_id}/messagesboth expose the same fields, so polling and history reads both get cost.
All fields are populated by Claude Code and OpenCode agents. They're omitted on messages produced by Cursor (which doesn't expose per-call usage) and on older messages from before this rolled out, so check before reading them.
See the message reference for field semantics.
Also in this update
- Tool fields on progress messages —
progressevents now exposetool_use_id,parent_tool_use_id,progress_type,tool_name, andtool_statusas top-level fields on the message response. You can correlate atool_usewith itstool_resultwithout parsing the JSONcontentblob. See the progress message fields reference. - API jobs now auto-archive on completion — when an agent signals it's done with an API-driven job (for example after a merged PR), the job is now marked
completedand the reason is appended to the conversation as asystemmessage. Previously API jobs stayedactiveforever and the agent remained assigned to them.