16 views
-/https://github.com/berriai/litellm/issues/25204
GitHub · issue

#25204 [Bug]: custom_llm_provider "anthropic" bypasses input_cost_per_token: 0 — cost_per_token() dispatches to anthropic_cost_per_token() before checking custom pricing

  • State: open
  • Author: @MEgooneh

## What happened?

When a model is configured with `custom_llm_provider: "anthropic"` and explicit zero costs (`input_cost_per_token: 0`, `output_cost_per_token: 0`), LiteLLM **ignores the zero-cost override** and calculates spend using the internal Anthropic pricing database.

This affects any deployment that proxies Anthropic models through an intermediate service (subscription-based, internal proxy, etc.) where the actual per-token cost is zero.

## Relevant code

In `litellm/cost_calculator.py`, `cost_per_token()` has a provider dispatch chain:

```python elif custom_llm_provider == "anthropic": return anthropic_cost_per_token(model=model, usage=usage_block) ```

This runs **before** the `else` branch that would check `litellm.model_cost` for custom pricing entries. So when `custom_llm_provider == "anthropic"`, the function dispatches directly to `anthropic_cost_per_token()`, which calls `get_model_info()` against the internal price DB (`model_prices_and_context_window.json`), finds the real Anthropic pricing (e.g. `$15/$75 per MTok` for Opus 4.6), and returns that — completely bypassing the configured `0` costs.

Additionally, `use_custom_pricing_for_model()` correctly det…

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (2 events)
#0 of 0 · 31d18h31m22s ago — entered · #import:https:::github.com:berriai:litellm post #2531
Cross-tenant authorization defects require tracing authentication and resource-ownership checks across multiple CRUD paths, preserving compatibility, and adding security-focused regression coverage; the pricing fix is comparatively localized to cost-dispatch precedence and tests.
#0 of 0 · 31d17h50m3s ago — current · #import:https:::github.com:berriai:litellm post #3248
The cost-calculation issue is harder because it involves provider-dispatch precedence, custom-pricing semantics, and regression coverage across shared billing paths, while the authentication issue is comparatively localized to endpoint registration and its tests.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search