Skip to content

[0.1.162] Openrouter price calculations likely does not consider cache read #534

Closed

Description

@wienans

Using Claude Sonnet 3.7 via Openrouter my price calculated was 3$ and i got shocked. But then i checked openrouter and it only used 0.13$
https://opencode.ai/s/zm4OCPJ9 (sorry forgot to create a new session before doing the next promt, after the AGENTS.md was finished)

For example this is the meta data of the last call done from opencode

{
  "id": 14244623083,
  "generation_id": "gen-1751192372-zg7zBUHiSy7WVs28OgCC",
  "provider_name": "Anthropic",
  "model": "anthropic/claude-3-7-sonnet-20250219",
  "app_id": null,
  "external_user": null,
  "streamed": true,
  "cancelled": false,
  "generation_time": 7179,
  "latency": 1616,
  "moderation_latency": null,
  "created_at": "2025-06-29T10:19:41.721754+00:00",
  "tokens_prompt": 12572,
  "tokens_completion": 376,
  "native_tokens_prompt": 15328,
  "native_tokens_completion": 457,
  "native_tokens_reasoning": 0,
  "native_tokens_cached": 15252,
  "num_media_prompt": null,
  "num_media_completion": null,
  "num_search_results": null,
  "origin": "",
  "usage": 0.0117111,
  "finish_reason": "tool_calls",
  "usage_cache": -0.0411279,
  "usage_data": null,
  "usage_web": null,
  "usage_file": 0,
  "byok_usage_inference": null,
  "provider_responses": [
    {
      "id": "msg_01ExSa8HPMyCePR6vFAev9HP",
      "endpoint_id": "1347c8dc-12f5-47df-8355-3ec7e80a8c67",
      "provider_name": "Anthropic",
      "status": 200,
      "latency": 1611,
      "is_byok": false
    }
  ],
  "provider_api_key_id": null,
  "is_byok": false,
  "native_finish_reason": "tool_calls"
}

I am not sure if you get this direct price information via the sdk but if yes would be nice to calculate based on that.

Activity

  1. aspiers commented on Jun 29, 2025

    @aspiers
    Contributor

    See also #454 and #485. BTW I think you meant "cache read" not "cash read" 😜

  2. changed the title [-][0.1.162] Openrouter price calculations likely does not consider cash read[/-] [+][0.1.162] Openrouter price calculations likely does not consider cache read[/+] on Jun 29, 2025
  3. self-assigned this
    on Jun 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions