Skip to content

[Feature]: Allow loading model cost map from external path / injected JSON #25062

Description

@eg-bole

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

The Feature

LiteLLM currently loads the “local fallback” model cost map from a JSON bundled inside the Python package (via importlib.resources). In packaged/bundled deployments (e.g., PyInstaller, slim Docker images), that bundled JSON may be missing, which can break offline fallback behavior.

Proposal: support user-provided local sources for the model cost map:

  • LITELLM_MODEL_COST_MAP_PATH=/path/to/model_cost_map.json (load JSON from file)

Pseudocode

@staticmethod
def load_local_model_cost_map() -> dict:
    path = os.getenv("LITELLM_MODEL_COST_MAP_PATH", "").strip()
    if path:
        with open(path, "r", encoding="utf-8") as f:
            return json.load(f)

    # existing fallback
    return json.loads(
        files("litellm")
        .joinpath("model_prices_and_context_window_backup.json")
        .read_text(encoding="utf-8")
    )

Motivation, pitch

This is mainly for offline/firewalled and packaged environments where:

  • remote fetch (GitHub raw) is blocked/unavailable, and
  • package data files (backup JSON) may be excluded by packaging/build tooling.

Related but not duplicates:

This change would make LiteLLM more reliable in air-gapped deployments and bundled binaries, while keeping current default behavior unchanged.

What part of LiteLLM is this about?

SDK (litellm Python package)

LiteLLM is hiring a founding backend engineer, are you interested in joining us and shipping to all our users?

No

Twitter / LinkedIn details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions