calculate_ai_cost
Calculate exact AI API call costs from model, token usage, caching, batch discounts, and platform fees, with currency conversion for text and non-text models.
Instructions
Calculate the exact cost of an AI API call with full base cost, prompt-caching, batch discount, and aggregator platform fee breakdown. Supports 60+ curated models and 400+ live OpenRouter models.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"model_id": "<model_id>"
},
"name": "calculate_ai_cost"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| batch | No | Apply Batch API discount if supported (default: false) | |
| units | No | Number of units for non-text models (images, seconds, minutes, songs, clips, 1M chars, or months) | |
| currency | No | Target currency code (default: 'USD') | |
| model_id | Yes | Model ID or alias (e.g., 'gpt-6.2-astra', 'claude-opus-5.5', 'gemini-4-carbon', 'grok-4.7', 'deepseek-v4.1-flash', 'veo-3.1') | |
| input_tokens | No | Uncached input tokens (for text models) | |
| output_tokens | No | Output completion tokens (for text models) | |
| cached_input_tokens | No | Cached input tokens billed at cache-read rate |