estimate_cost
Calculate the USD cost of a Perplexity API request upfront, with a breakdown by input tokens, output tokens, and tool calls.
Instructions
Estimate the USD cost of a request before sending it. Returns a breakdown by input tokens, output tokens, and tool invocations.
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": "<model>",
"input_tokens": "<input_tokens>"
},
"name": "estimate_cost"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| model | Yes | Model ID to estimate cost for (e.g. 'sonar', 'sonar-pro'). | |
| input_tokens | Yes | Number of input (prompt) tokens. | |
| output_tokens | No | Number of output (completion) tokens. | |
| tool_invocations | No | Tool invocation counts (for models that bill per tool call). |