Get Account Logs
GET /api/open/v1/logsRequest parameters
Section titled “Request parameters”| Parameter | In | Type | Required | Default | Description |
|---|---|---|---|---|---|
start_timestamp | query | integer | No | See below | Start time (inclusive), unix seconds |
end_timestamp | query | integer | No | See below | End time (inclusive), unix seconds |
model_name | query | string | No | — | Exact model name; repeat the parameter for multiple values (?model_name=a&model_name=b) or separate values with commas |
key_name | query | string | No | — | Exact Key name; repeat the parameter for multiple values. Commas are not supported because names may contain commas |
key_id | query | integer | No | — | Key ID, a positive integer; repeat the parameter or separate values with commas. IDs that belong to other users return no rows |
type | query | integer | No | 2 | Log type: 2 for consumption (billed) requests, 7 for final failed requests (not billed). Repeat the parameter or separate values with commas (?type=2,7); other values return 400 |
p | query | integer | No | 1 | Page number, from 1 to 1000000 |
page_size | query | integer | No | 10 | Items per page, from 1 to 1000 |
Time range rules:
- Both omitted: the last 30 days.
- Only
start_timestamp: 30 days forward, capped at the current time. - Only
end_timestamp: 30 days backward. - The range can be at most 366 days.
Each multi-value parameter accepts at most 50 values; more returns 400 invalid_request. Explicitly supplied invalid p / page_size return 400; see Pagination. Timestamps must be non-negative integers, otherwise 400.
Request example
Section titled “Request example”curl "https://www.routeapi.ai/api/open/v1/logs?start_timestamp=1726408000&end_timestamp=1729000000&key_name=bot&model_name=gpt-4o&p=1&page_size=20" \ -H "Authorization: Bearer $ROUTEAPI_MANAGEMENT_KEY"Response example
Section titled “Response example”{ "success": true, "message": "", "data": { "items": [ { "id": 12345, "created_at": 1729000000, "type": 2, "key_id": 12, "key_name": "bot", "key": "sk-abcd**********wxyz", "model_name": "gpt-4o", "prompt_tokens": 1200, "completion_tokens": 300, "total_tokens": 1500, "amount": 0.05, "use_time": 3, "is_stream": true, "first_response_ms": 420, "cache_read_tokens": 800, "cache_creation_tokens": 0, "reasoning_effort": "medium", "request_path": "/v1/chat/completions", "web_search_calls": 0, "audio_input_tokens": 0, "audio_output_tokens": 0, "billing_source": "wallet", "request_id": "20261020120000123456789" } ], "total": 1, "page": 1, "page_size": 20, "start_timestamp": 1726408000, "end_timestamp": 1729000000 }}Response fields
Section titled “Response fields”| Field | Type | Description |
|---|---|---|
items[].id | integer | Log ID |
items[].created_at | integer | Log time, unix seconds |
items[].type | integer | 2 consumption, 7 final request failure |
items[].key_id | integer | ID of the Key that made the request |
items[].key_name | string | Name of the Key at the time of the request |
items[].key | string | Masked Key value in the same format as List API Keys, for example sk-abcd**********wxyz; empty string if the Key has been permanently deleted |
items[].model_name | string | Model name |
items[].prompt_tokens | integer | Input tokens |
items[].completion_tokens | integer | Output tokens |
items[].total_tokens | integer | Input plus output tokens |
items[].amount | number | Amount consumed in the site currency, two decimals; may be 0.00 for very small amounts |
items[].use_time | integer | Request duration, seconds |
items[].is_stream | boolean | Whether the request was streamed |
items[].first_response_ms | integer | Time to first response, milliseconds; 0 if unknown (for example non-streamed requests) |
items[].cache_read_tokens | integer | Prompt cache hit tokens |
items[].cache_creation_tokens | integer | Prompt cache write tokens |
items[].reasoning_effort | string | Reasoning effort such as low, medium, or high; empty string if not set |
items[].request_path | string | Request path, for example /v1/chat/completions |
items[].web_search_calls | integer | Number of web search calls made during the request |
items[].audio_input_tokens | integer | Audio input tokens |
items[].audio_output_tokens | integer | Audio output tokens |
items[].billing_source | string | wallet for wallet balance, subscription for a subscription plan, empty string if unknown |
items[].request_id | string | Request ID, useful for troubleshooting |
total | integer | Number of matching logs, counted up to 10000 |
page | integer | Current page number |
page_size | integer | Effective items per page |
start_timestamp | integer | Effective start time |
end_timestamp | integer | Effective end time |
Errors
Section titled “Errors”| HTTP | code | Scenario |
|---|---|---|
| 400 | invalid_request | A timestamp is not numeric or is negative, the range exceeds 366 days, start_timestamp is greater than end_timestamp, the pagination parameters are invalid, a multi-value parameter has more than 50 values, key_id is not a positive integer, or type is not 2 or 7 |
| 429 | — | Per-user query rate limit exceeded (default 30/minute); the body may be empty |
For other common error codes, see Platform API errors.
- By default only consumption (billing) logs are returned. Add
type=2,7to include final failed requests (not billed) as well. - Results are sorted by
created_atdescending (newest first); records with the same timestamp are ordered by log ID descending, so paging is stable. key_nameis the Key’s name at the time of the request; renaming a Key does not rewrite past records.keyis the masked value; it is an empty string when the Key has since been permanently deleted.use_time,first_response_ms, cache, search, audio, and reasoning fields are0or an empty string when the corresponding data was not recorded; fields are always present.- Token counts are raw counts, not millions.
- Amounts use the site display currency; see Get balance.
- This endpoint shares the per-user query rate limit (default 30/minute) with Export logs, Usage, Usage by model, and Usage by Key. See Rate limits.
- To export all matching rows at once (CSV or JSONL), use Export logs instead of paging and concatenating this endpoint.