Cost Breakdown
Get real-time cost data for every AI request directly in the API response.
Cost Breakdown
RouterBench includes cost data in every API response, so you can track spending programmatically without checking a dashboard. Know exactly what each request costs the moment it completes.
Cost breakdowns are included automatically for all verified accounts.
Response Format
Every completion response includes an extended usage object with cost details:
{
"id": "tx_routerbench_98765",
"object": "chat.completion",
"created": 1700000000,
"model": "gpt-4o",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Analysis complete. The requested data has been processed."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 120,
"completion_tokens": 45,
"total_tokens": 165,
"cost_usd_total": 0.00345,
"cost_usd_input": 0.0018,
"cost_usd_output": 0.00165,
"cost_usd_cached_input": 0,
"cost_usd_request": 0,
"cost_usd_web_search": 0.0
}
}Cost Fields
| Field | Description |
|---|---|
cost_usd_total | Total inference cost for this request (excludes storage). |
cost_usd_input | Cost of processing input/prompt tokens. |
cost_usd_output | Cost of generating completion tokens. |
cost_usd_cached_input | Savings from cached tokens (when provider caching applies). |
cost_usd_request | Fixed per-request cost (for models with request-based pricing). |
cost_usd_web_search | Cost of web search queries for this request. |
cost_usd_total is the sum of all individual cost fields for this request.
Streaming
Cost data is included in the final chunk of streamed responses, right before the [DONE] signal:
data: {"id":"tx_routerbench_123","usage":{"prompt_tokens":50,"completion_tokens":100,"cost_usd_total":0.0025,"cost_usd_input":0.0005,"cost_usd_output":0.0020}}
data: [DONE]Example: Budget Tracking
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.routerbench.com/v1",
apiKey: process.env.ROUTERBENCH_API_KEY,
});
async function processRequest() {
const completion = await client.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Perform a comprehensive audit." }],
});
const { usage } = completion as any;
if (usage?.cost_usd_total) {
console.log(`Cost: $${usage.cost_usd_total.toFixed(4)}`);
}
}Currency
RouterBench bills entirely in USD ($) — everywhere.
| Where | Currency | Why |
|---|---|---|
API response (cost_usd_*) | USD ($) | Matches provider pricing (OpenAI, Google, Groq all price in USD). |
| Dashboard & billing | USD ($) | Credits are topped up and deducted in USD via Stripe. |
How It Works
- You top up credits in USD (e.g., $100 via Stripe)
- Each API request's cost is calculated in USD (e.g., $0.000003 for a gpt-4o-mini call)
- The USD cost is deducted from your credit balance
- Both the API response and the dashboard show USD, so costs always match provider pricing
Example
API response: cost_usd_total = $0.000003 (what the provider charges)
Credit deducted: $0.000003
Dashboard shows: $99.999997 remainingUse Cases
- Budget Alerts: Set up alerts when individual requests or users exceed a cost threshold.
- Per-User Billing: Track exact costs per user in multi-tenant apps.
- Model Selection: Compare costs across models to pick the most cost-effective option for each task.
How is this guide?