Skip to main content
Routeway’s account endpoints let you programmatically track spending and usage without visiting the dashboard. This is useful for building internal dashboards, setting up alerts, or auditing costs.
All endpoints on this page require a management key. Create one from Dashboard → Management Keys.

Check Your Balance

GET /v1/account/balance returns your current credit balance in dollars.
import os
import requests

headers = {"Authorization": f"Bearer {os.getenv('ROUTEWAY_MANAGEMENT_KEY')}"}

response = requests.get("https://api.routeway.ai/v1/account/balance", headers=headers)
data = response.json()

print(f"Current balance: ${data['balance']:.2f}")
Response:
{
  "balance": 4.20
}
Use this endpoint to implement low-balance alerts. Poll periodically and notify your team when the balance drops below a threshold.

Request Activity

GET /v1/account/activity returns a paginated list of individual request logs, including the model used, cost, and timestamp.

Parameters

ParameterTypeDefaultDescription
limitinteger50Number of records to return (1–200)
offsetinteger0Offset for pagination
import os
import requests

headers = {"Authorization": f"Bearer {os.getenv('ROUTEWAY_MANAGEMENT_KEY')}"}

response = requests.get(
    "https://api.routeway.ai/v1/account/activity",
    headers=headers,
    params={"limit": 10, "offset": 0}
)

data = response.json()

for entry in data["data"]:
    print(f"{entry['created_at']} | {entry['model']:20s} | ${entry['cost']:.5f}")

print(f"\nShowing {len(data['data'])} of results (offset: {data['offset']})")
Response:
{
  "data": [
    {
      "model": "gpt-4o",
      "cost": 0.00042,
      "created_at": "2025-06-15T12:00:00Z"
    },
    {
      "model": "claude-sonnet-4-20250514",
      "cost": 0.00128,
      "created_at": "2025-06-15T11:58:30Z"
    }
  ],
  "limit": 10,
  "offset": 0
}

Pagination

To fetch all activity, increment offset by limit until the returned data array is empty:
all_activity = []
offset = 0
limit = 200

while True:
    response = requests.get(
        "https://api.routeway.ai/v1/account/activity",
        headers=headers,
        params={"limit": limit, "offset": offset}
    )
    page = response.json()
    all_activity.extend(page["data"])

    if len(page["data"]) < limit:
        break
    offset += limit

print(f"Total requests: {len(all_activity)}")

Usage Analytics

GET /v1/account/analytics returns aggregated usage metrics over a time window. Results are cached server-side for 5 minutes.

Parameters

ParameterTypeDefaultDescription
periodstring"30d"Time window: "24h", "7d", "30d", or "all"
modelstringFilter metrics to a specific model ID
import os
import requests

headers = {"Authorization": f"Bearer {os.getenv('ROUTEWAY_MANAGEMENT_KEY')}"}

# Get last 7 days of usage
response = requests.get(
    "https://api.routeway.ai/v1/account/analytics",
    headers=headers,
    params={"period": "7d"}
)

# Check cache status
cache_status = response.headers.get("X-Cache", "MISS")
print(f"Cache: {cache_status}")

analytics = response.json()
print(analytics)
The X-Cache response header tells you whether the result was served from cache (HIT) or freshly computed (MISS). Analytics are cached for 5 minutes, so rapid repeated calls will return the same data without extra processing.

Rate Limits

You can find more information about rate limits here.

Common Use Cases

Low-balance alerts

Poll /v1/account/balance every few minutes and send a Slack/email alert when balance drops below a threshold.

Cost attribution

Use /v1/account/activity to break down costs by model and time period for internal billing or chargeback.

Usage dashboards

Feed /v1/account/analytics into Grafana, Datadog, or a custom dashboard to visualize trends.

Budget automation

Combine balance checks with key management to auto-disable keys when a budget threshold is reached.