Get chat cost
GET
Cost covers the whole chat tree: the root chat plus every subagent chat beneath it. Requesting cost for a subagent chat returns that same total.
Cost is derived from AI Gateway data, which is subject to its own retention period, 60 days by default, configured independently of chat retention. Spend for requests older than that period is no longer reported, so a chat whose requests have all been purged reports zero cost.
CoderSessionTokenheader
Coder-Session-Token<token>chat*stringChat ID
Format
uuidOK
application/json- response
chat_id?stringFormat
uuidrequest_count?integertotal_cost_micros?integerunpriced_request_count?integerThe samples read CODER_URL and CODER_SESSION_TOKEN: set up your environment.
curl -X GET \ "$CODER_URL/api/v2/chats/{chat}/cost" \ -H "Coder-Session-Token: $CODER_SESSION_TOKEN"Example Response200
{ "chat_id": "efc9fe20-a1e5-4a8c-9c48-f1b30c1e4f86", "request_count": 0, "total_cost_micros": 0, "unpriced_request_count": 0}