usage
Get usage statistics
Section titled “Get usage statistics”Query token usage records within a specified time range
Request
Section titled “Request”GET /usage?start_time=1735689600&end_time=1736294400Query Parameters
Section titled “Query Parameters”| Field | Type | Required | Description |
|---|---|---|---|
| start_time | integer | Yes | Start time (Unix timestamp) |
| end_time | integer | Yes | End time (Unix timestamp) |
Request Examples
Section titled “Request Examples”curl -X GET "https://portal-api.r9s.ai/api/v1/portal/management/usage?start_time=1735689600&end_time=1736294400" \ -H "Authorization: Bearer sk_mg_xxxxxxxxxxxxxxxxxx"JavaScript (Fetch)
Section titled “JavaScript (Fetch)”const response = await fetch('https://portal-api.r9s.ai/api/v1/portal/management/usage?start_time=1735689600&end_time=1736294400', { method: 'GET', headers: { 'Authorization': 'Bearer sk_mg_xxxxxxxxxxxxxxxxxx', 'Content-Type': 'application/json' }});
const data = await response.json();console.log(data);Python (requests)
Section titled “Python (requests)”import requests
url = "https://portal-api.r9s.ai/api/v1/portal/management/usage"params = { "start_time": 1735689600, "end_time": 1736294400}headers = { "Authorization": "Bearer sk_mg_xxxxxxxxxxxxxxxxxx", "Content-Type": "application/json"}
response = requests.get(url, params=params, headers=headers)data = response.json()print(data)Successful response
Response Schema
Section titled “Response Schema”| Field | Type | Required | Description |
|---|---|---|---|
| meta | object | Yes | Response metadata |
| meta.code | integer | Yes | HTTP status code |
| meta.message | string | Yes | Response message |
| meta.request_id | string | Yes | Request identifier |
| data | object | Yes | Usage data |
| data.records | array | Yes | Usage records list |
| data.records[].timestamp | integer | Yes | Record timestamp |
| data.records[].tokens | integer | Yes | Token usage count |
| data.records[].model | string | Yes | Model name |
| data.total_tokens | integer | Yes | Total tokens used |
Response Example
Section titled “Response Example”{ "meta": { "code": 200, "message": "success", "request_id": "abc123" }, "data": { "records": [ { "timestamp": 1735689600, "tokens": 1500, "model": "gpt-4o-mini" }, { "timestamp": 1735776000, "tokens": 2300, "model": "gpt-4o-mini" } ], "total_tokens": 3800 }}Related APIs
Section titled “Related APIs”- Manager API Overview - Learn about Manager API authentication and basic information
- balance - Retrieve current account balance information