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.
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} " )
const response = await fetch ( "https://api.routeway.ai/v1/account/balance" , {
headers: { Authorization: `Bearer ${ process . env . ROUTEWAY_MANAGEMENT_KEY } ` },
});
const { balance } = await response . json ();
console . log ( `Current balance: $ ${ balance . toFixed ( 2 ) } ` );
curl https://api.routeway.ai/v1/account/balance \
-H "Authorization: Bearer $ROUTEWAY_MANAGEMENT_KEY "
Response:
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
Parameter Type Default Description limitinteger 50Number of records to return (1–200) offsetinteger 0Offset 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 " \n Showing { len (data[ 'data' ]) } of results (offset: { data[ 'offset' ] } )" )
const params = new URLSearchParams ({ limit: "10" , offset: "0" });
const response = await fetch (
`https://api.routeway.ai/v1/account/activity? ${ params } ` ,
{ headers: { Authorization: `Bearer ${ process . env . ROUTEWAY_MANAGEMENT_KEY } ` } }
);
const { data , limit , offset } = await response . json ();
for ( const entry of data ) {
console . log ( ` ${ entry . created_at } | ${ entry . model . padEnd ( 20 ) } | $ ${ entry . cost . toFixed ( 5 ) } ` );
}
curl "https://api.routeway.ai/v1/account/activity?limit=10&offset=0" \
-H "Authorization: Bearer $ROUTEWAY_MANAGEMENT_KEY "
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
}
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
Parameter Type Default Description periodstring "30d"Time window: "24h", "7d", "30d", or "all" modelstring — Filter 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)
const response = await fetch (
"https://api.routeway.ai/v1/account/analytics?period=7d" ,
{ headers: { Authorization: `Bearer ${ process . env . ROUTEWAY_MANAGEMENT_KEY } ` } }
);
const cacheStatus = response . headers . get ( "X-Cache" ) ?? "MISS" ;
console . log ( `Cache: ${ cacheStatus } ` );
const analytics = await response . json ();
console . log ( analytics );
# Last 7 days, all models
curl "https://api.routeway.ai/v1/account/analytics?period=7d" \
-H "Authorization: Bearer $ROUTEWAY_MANAGEMENT_KEY "
# Last 24 hours, specific model
curl "https://api.routeway.ai/v1/account/analytics?period=24h&model=gpt-4o" \
-H "Authorization: Bearer $ROUTEWAY_MANAGEMENT_KEY "
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.