BerriAI/litellm · error · ValueError

Field {field} should be a valid dictionary

Error message

Field {field} should be a valid dictionary

What it means

Proxy config normalization tries to json.loads string values of dict-typed fields (metadata, aliases, config, permissions, etc.); when parsing fails the field stays a string and this error reports the field that could not be coerced to a dictionary.

Source

Thrown at litellm/proxy/_types.py:1215

        if values.get("token") is not None:
            values.update({"key": values.get("token")})
        dict_fields: Final = [
            "metadata",
            "aliases",
            "config",
            "permissions",
            "model_max_budget",
            "budget_fallbacks",
            "router_settings",
            "budget_limits",
        ]
        for field in dict_fields:
            value = values.get(field)
            if value is not None and isinstance(value, str):
                try:
                    values[field] = json.loads(value)
                except json.JSONDecodeError:
                    raise ValueError(f"Field {field} should be a valid dictionary")

        return values


class UpdateKeyRequest(KeyRequestBase):
    # Note: the defaults of all Params here MUST BE NONE
    # else they will get overwritten
    duration: str | None = None
    spend: float | None = None
    metadata: dict | None = None
    temp_budget_increase: float | None = None
    temp_budget_expiry: datetime | None = None
    auto_rotate: bool | None = None
    rotation_interval: str | None = None
    organization_id: str | None = None

    @model_validator(mode="after")
    def validate_temp_budget(self) -> "UpdateKeyRequest":

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Pass a dictionary (object) for the indicated field.

Example fix

field={"key": "value"}
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at litellm/proxy/_types.py:1215 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/15146091c5efe3cf. Report an issue: GitHub.