1_000_000_000 is $1.
Account position
Read available credit, scoped grants, and the latest upstream usage events.
One routed request
Use
X-Request-Id to see total cost, selected model, and candidate ranking.All usage endpoints accept the same API key or bearer authentication as model
requests. They are intentionally available even when an account has no credit.
Account position
GET /v1/usage is the starting point for billing UI, account summaries, and a
simple “how much did I spend?” view. It returns the credit ceiling and consumed
credit plus recent provider-level cost events.
| Field | Meaning |
|---|---|
limit_nanos | The account credit ceiling. |
used_nanos | Credit consumed so far. |
grants[] | Active credit grants, including their remaining amount and optional routing/provider scope. |
recent_events[] | Recent upstream model legs with token counts and cost_nanos. |
limit to change the recent-event count. It defaults to 20 and caps at
200.
One routed request
Every model response includesX-Request-Id. Store it with your application
trace, then use it to answer the questions users actually ask: what did this
turn cost, which model answered, and which routing policy ran?
total_cost_nanos,total_input_tokens, andtotal_output_tokensselected_model_idandprovider_ranksrouting_mode(pro,max, orultra_saver)- optional
session_id,agent_id, andsession_sourcefields for coding-agent workloads
Explore routed requests
Historical requests
GET /v1/usage/requests is cursor-paginated and works well for activity feeds.Session totals
Group coding-agent work by session and fetch aggregate cost/request count.
Feedback
Attach thumbs and structured cost/quality feedback to a completed request.
Historical requests
GET /v1/usage/requests returns { "items": [...], "has_more": true|false }.
Pass both before (an RFC 3339 timestamp) and before_id from the last item to
load an older page. Use session_id to restrict results to one session.
Session totals
| Endpoint | Use it for |
|---|---|
GET /v1/usage/sessions?ids=a,b,c | Aggregate request_count and total_cost_nanos for up to 100 known sessions. |
GET /v1/usage/sessions/list?limit=30 | Discover recent sessions, ordered by latest activity. Default is 30; max is 100. |
Rate a request
POST /v1/usage/requests/{request_id}/feedback records a thumbs rating or an
optional comment. Include a structured reason such as too_expensive,
too_slow, great_value, stronger_model_needed, or wrong_model to make
cost/quality feedback useful for routing analysis.