Give me example how cost is calculated based on tokens

I used Cursor Admin API to acquire tokens cost data in order to predict my budget after new pricing for teams from 9/15.

However, the request cost doesn’t match when I try to verify the consumed tokens with official pricing list. Could you explain how [totalCents] comes out for below 3 examples?

model requestsCosts isTokenBasedCall inputTokens outputTokens cacheWriteTokens cacheReadTokens totalCents
claude-4-sonnet 1 FALSE 57671 55841 119833 18807260 683.862045
claude-4-sonnet 1 FALSE 1781167 2721 0 0 538.4316
claude-4-sonnet 1 FALSE 45 25461 242130 9892292 425.77251

Claude Sonnet 4

Input
Prompts ≤ 200K tokens
$3 / MTok
Prompts > 200K tokens
$6 / MTok

Output
Prompts ≤ 200K tokens
$15 / MTok
Prompts > 200K tokens
$22.50 / MTok

Prompt caching
≤ 200K tokens
Write $3.75 / MTok
Read $0.30 / MTok

200K tokens
Write $7.50 / MTok
Read $0.60 / MTok

hi @xianglai1.li here is a summary of how this works.

Details:

  • Input tokens: 57,671
  • Output tokens: 55,841
  • Cache write tokens: 119,833
  • Cache read tokens: 18,807,260
  • Anthropic pricing (≤ 200K tokens per category):
    • Input: $3 per 1M tokens
    • Output: $15 per 1M tokens
    • Cache write: $3.75 per 1M tokens
    • Cache read: $0.30 per 1M tokens

Step-by-step calculation:

Category Token Count Rate per 1M Formula Cost (USD)
Input 57,671 $3 57,671 / 1,000,000 × $3 $0.173
Output 55,841 $15 55,841 / 1,000,000 × $15 $0.837
Cache Write 119,833 $3.75 119,833 / 1,000,000 × $3.75 $0.449
Cache Read 18,807,260 $0.30 18,807,260 / 1,000,000 × $0.30 $5.642

Total cost:
$0.173 + $0.837 + $0.449 + $5.642 = $7.10
or
$7.10 × 100 = 710 cents

Note: The final “totalCents” billed by Cursor are slightly lower at 683.86 cents as shown in your post.

Formula for each line:

(token_count / 1,000,000) × (rate per 1M tokens)

Then add up all categories for the total.

1 Like

Thanks for you reply, two more questions:

1)Why always ≤ 200K tier is applied though [Cache read tokens] is much higher than 200K? Is it decided by model selection or the way Cursor makes LLM request? For example, if I choose claude-4-sonnet (200K context window), there will never be >200K pricing, right?

2)As you said, Cursor bills less than the calculated result. Is it fixed discount or dynamic discount? Based on what?

1 Like

I will check with the team for your follow up questions and let you know. good point!

I got more details:

The <200k cost is applied as the input tokens count here for the price. Above 200k input tokens Anthropic charges more.

There is no discount for this case. You are only charged for the amount billed, so in this case the difference is waived.