BerriAI/litellm · error · Exception

Unable to calculat cost for received potential model names -

Error message

Unable to calculat cost for received potential model names - {potential_model_names}

What it means

After trying every candidate model name (stripped prefixes, mapped variants) against the known pricing tables, no cost row matched; the list of attempted names is included so the unrecognized model can be identified — typically an unmapped or misspelled model.

Source

Thrown at litellm/cost_calculator.py:1693

                        discount_amount=discount_amount,
                        margin_percent=margin_percent,
                        margin_fixed_amount=margin_fixed_amount,
                        margin_total_amount=margin_total_amount,
                        cache_read_cost=_cache_read_cost,
                        cache_creation_cost=_cache_creation_cost,
                        reasoning_cost=_reasoning_cost,
                        service_tier=service_tier,
                        data_residency=data_residency,
                    )

                return _final_cost
            except Exception as e:
                verbose_logger.debug(
                    "litellm.cost_calculator.py::completion_cost() - Error calculating cost for model=%s - %s", model, e
                )
                if idx == len(potential_model_names) - 1:
                    raise e
        raise Exception(f"Unable to calculat cost for received potential model names - {potential_model_names}")
    except Exception as e:
        raise e


def get_response_cost_from_hidden_params(
    hidden_params: dict | BaseModel,
) -> float | None:
    if isinstance(hidden_params, BaseModel):
        _hidden_params_dict = cast(BaseModel, hidden_params).model_dump()
    else:
        _hidden_params_dict = hidden_params

    additional_headers: Final = _hidden_params_dict.get("additional_headers", {})
    if additional_headers and "llm_provider-x-litellm-response-cost" in additional_headers:
        response_cost: Final = additional_headers["llm_provider-x-litellm-response-cost"]
        if response_cost is None:
            return None
        return float(additional_headers["llm_provider-x-litellm-response-cost"])

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Check that the model name (or its aliases) exists in the litellm cost map; none of the tried names had pricing.
  2. Register custom pricing for the model, or correct the model name spelling.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/cost_calculator.py:1693 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/eff853fbd23801b4. Report an issue: GitHub.