Cost Information Now Included in API Response JSON!

We’re excited to share a new update for all Sonar API users: the API response JSON now includes detailed cost information for each request!

You’ll now see a new structure like this in your response:

“usage”: {
“prompt_tokens”: 8,
“completion_tokens”: 439,
“total_tokens”: 447,
“search_context_size”: “low”,
“cost”: {
“input_tokens_cost”: 2.4e-05,
“output_tokens_cost”: 0.006585,
“request_cost”: 0.006,
“total_cost”: 0.012609
}
}

What’s included?

  • input_tokens_cost: Cost attributed to input tokens.

  • output_tokens_cost: Cost attributed to output tokens.

  • request_cost: Fixed cost per request.

  • total_cost: The total cost for this API call.

This update enables easier tracking of usage and billing directly from each API response.

If you have feedback or questions, drop them below!

2 Likes