Skip to content
Skip to Content
Coder Docs

Get chat cost

GET
/api/v2/chats/{chat}/cost

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.

Authorization

CoderSessionToken
headerCoder-Session-Token<token>

Path Parameters

chat*string

Chat ID

Formatuuid

Response Body

OK

application/json
  1. response
chat_id?string
Formatuuid
request_count?integer
total_cost_micros?integer
unpriced_request_count?integer

The 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}