BerriAI/litellm · error · Exception

Model not found in cost map for model={model}

Error message

Model not found in cost map for model={model}

What it means

The default video-cost calculator tries several candidate model names (with quality/resolution variants and provider prefixes) against litellm.model_cost; if none matches, it raises this generic Exception — the video model has no entry in LiteLLM's pricing data, so per-second video cost cannot be resolved.

Source

Thrown at litellm/cost_calculator.py:2082

        models_to_check: Final[list[str | None]] = [
            base_model_name,
            model,
            model_without_provider,
            model_name_without_custom_llm_provider,
        ]
        for _model in models_to_check:
            if _model is not None and _model in litellm.model_cost:
                cost_info = litellm.model_cost[_model]
                break

        # If still not found, try with custom_llm_provider prefix
        if cost_info is None and custom_llm_provider:
            prefixed_model: Final = f"{custom_llm_provider}/{model}"
            if prefixed_model in litellm.model_cost:
                cost_info = litellm.model_cost[prefixed_model]

    if cost_info is None:
        raise Exception(f"Model not found in cost map for model={model}")

    # Check for video-specific cost per second first
    video_cost_per_second: Final = cost_info.get("output_cost_per_video_per_second")
    if video_cost_per_second is not None:
        return video_cost_per_second * duration_seconds

    output_cost_per_second: Final = _video_output_cost_per_second(cost_info, video_resolution)
    if output_cost_per_second is not None:
        return output_cost_per_second * duration_seconds

    # If no cost information found, return 0
    verbose_logger.info(
        "No cost information found for video model %s. Please add pricing to model_prices_and_context_window.json",
        model,
    )
    return 0.0

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Update LiteLLM to get current video pricing data.
  2. Register the model: litellm.register_model({'model-id': {'output_cost_per_video_per_second': ...}}).
  3. Alias your deployment's model name to a known base model in the router's model_info.
  4. Catch and log-zero for unmapped video models if billing is handled externally.

Example fix

# before
cost = litellm.cost_calculator.default_video_cost_calculator("acme-video-v2", 12.0)

# after
litellm.register_model({"acme-video-v2": {"output_cost_per_video_per_second": 0.10}})
cost = litellm.cost_calculator.default_video_cost_calculator("acme-video-v2", 12.0)
Defensive patterns

Strategy: validation

Validate before calling

import litellm

if model not in litellm.model_cost and model.split("/")[-1] not in litellm.model_cost:
    litellm.register_model({model: {"output_cost_per_video_per_second": fallback}})

Type guard

def video_model_priced(model: str, provider: str | None = None) -> bool:
    candidates = [model, f"{provider}/{model}" if provider else None, model.split("/")[-1]]
    return any(c and c in litellm.model_cost for c in candidates)

Try / catch

try:
    cost = default_video_cost_calculator(model, duration_seconds, custom_llm_provider=provider)
except Exception as e:
    if "not found in cost map" in str(e):
        litellm.register_model({model: {"output_cost_per_video_per_second": fallback}})
        cost = default_video_cost_calculator(model, duration_seconds, custom_llm_provider=provider)
    else:
        raise

Prevention

When it happens

Trigger: Computing video-generation cost for a model absent from model_prices_and_context_window.json and not registered with litellm.register_model; niche or new video models (e.g. regional variants) with unmapped names.

Common situations: Recently released video models on an older LiteLLM install; custom model ids from router deployments; user-supplied model strings flowing into cost logging.

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/bb2131cc3b4607e2. Report an issue: GitHub.