Skip to content

Token & Cost count does not function with a custom provider #993

Description

@KiaArmaniHees

Describe the bug

When using a custom provider (Azure OpenAI via LiteLLM), tokens aren't being counted and cost isn't shown.

Setup

Please complete the following information along with version numbers, if applicable.

  • Windows 11 23H2
  • Powershell 5.1.22621.2706

To Reproduce

Steps to reproduce the behavior:

  1. Create a crush.json with the following content:
{
  "$schema": "https://charm.land/crush.json",
  "providers": {
    "your-custom-provider": {
      "type": "openai",
      "base_url": "https://litellm.local.host/v1",
      "api_key": "REDACTED",
      "models": [
        {
          "id": "gpt-5",
          "name": "GPT-5",
          "context_window": 400000,
          "default_max_tokens": 16384,
          "cost_per_1m_in": 1.25,
          "cost_per_1m_out": 10.0
        },
        {
          "id": "gpt-5-mini",
          "name": "GPT-5-Mini",
          "context_window": 400000,
          "default_max_tokens": 8192,
          "cost_per_1m_in": 0.25,
          "cost_per_1m_out": 2.0
        }
      ]
    }
  },
  "models": {
    "large": {
      "model": "gpt-5",
      "provider": "your-custom-provider"
    }
  }
}
  1. Launch crush
  2. Make any request
  3. Token count and cost remain at 0 and $0.00 respectively.

Expected behavior

Token and cost count should match the tokens used count and the calculated cost based on cost_per_1m_in and cost_per_1m_out.

Screenshots

Image

Additional context

This issue does not occur with a built-in provider (i.e. using OpenAI directly using an API Key).


Maintainers’ note: Formatted JSON for readability.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions