Usage And Token Counting API
Usage reports consumption for a Key, while token counting estimates input size before a request. They are not interchangeable; final billing comes from completed-request usage records.
Authentication
The /v1 endpoints use the API Key form required by the current protocol. This generic example uses a Bearer token:
curl https://quotarouter.ai/v1/usage \
-H "Authorization: Bearer YOUR_QUOTAAPI_KEY"Endpoints
| Method | Path | Purpose |
|---|---|---|
| GET | /v1/usage | Usage information for the current Key |
| GET | /v1/models | Models visible to the current Key |
| POST | /v1/messages/count_tokens | Count input tokens for a Messages request |
| POST | /messages/count_tokens | Client-compatible alias without /v1 |
| POST | /v1/live | Create a supported live call |
| GET | /v1/live/:call_id | Read sideband information for a live call |
Count tokens
curl https://quotarouter.ai/v1/messages/count_tokens \
-H "x-api-key: YOUR_QUOTAAPI_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4.5",
"messages": [{ "role": "user", "content": "Count this request." }]
}'Typical response:
{
"input_tokens": 12
}OpenAI uses a bridge, Grok uses a local estimate, DeepSeek returns unsupported, and other platforms retain their native counting path. The estimate does not include generated output tokens.
List models
curl "https://quotarouter.ai/v1/models?client_version=1.0.0" \
-H "Authorization: Bearer YOUR_QUOTAAPI_KEY"Codex clients can include client_version to receive an adapted model manifest. Other clients receive the regular model list. Both remain constrained by the Key group and model mappings.
Live endpoints
Live serves Codex/OpenAI workflows that explicitly support realtime calls. Preserve the returned call_id and query /v1/live/:call_id for sideband data. Ordinary Chat Completions and Messages clients do not need Live.
Relationship to console records
The /usage console page records completed-request model, tokens, charge, latency, and status. A successful estimate does not guarantee generation success or determine the final charge.
