Skip to content

Read costs per model #12

Description

@JCHacking

What problem are you trying to solve?

Check the costs by model and send them to OpenCode to ensure the cost is correct

Proposed solution

In the /v1/model/info endpoint, the model_info object has several properties, such as:

  • cache_read_input_token_cost
  • input_cost_per_token
  • output_cost_per_token
  • cache_creation_input_token_cost

From which data can be extracted for this purpose

The problem is that some models have additional settings configured, such as:

  • cache_creation_input_token_cost_above_1hr
  • cache_creation_input_token_cost_above_200k_tokens
  • cache_read_input_token_cost_above_200k_tokens
  • cache_read_input_token_cost_above_200k_tokens_priority
  • cache_read_input_token_cost_flex
  • cache_read_input_token_cost_priority
  • citation_cost_per_token
  • input_cost_per_token_above_128k_tokens
  • input_cost_per_second
  • input_cost_per_image
  • output_cost_per_token_above_128k_tokens
    etc

The initial implementation only considers the first 4 (#11)
But depending on the number of tokens, we would need to better calculate the

Alternatives considered

Use /spend to view costs
This works if you have administrator permissions. However, if you're using a Litellm managed by someone else who doesn't have these permissions, you won't be able to view that endpoint.

Scope check

  • My request is related to LiteLLM model discovery, configuration, or routing

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions