BerriAI/litellm · error · ValueError

Invalid environment: {environment}. Please use one of the fo

Error message

Invalid environment: {environment}. Please use one of the following instead: {valid_values}

What it means

DeepEval integration tags traces with an environment label taken from LITELLM_ENVIRONMENT (default 'development'). validate_environment checks the value against the Environment enum — production, development, staging — and raises ValueError for anything else, listing the allowed values in the message. It runs during DeepEvalLogger construction, before any API call.

Source

Thrown at litellm/integrations/deepeval/utils.py:14

from datetime import datetime, timezone
from typing import Final

from litellm.integrations.deepeval.types import Environment


def to_zod_compatible_iso(dt: datetime) -> str:
    return dt.astimezone(timezone.utc).isoformat(timespec="milliseconds").replace("+00:00", "Z")


def validate_environment(environment: str):
    if environment not in [env.value for env in Environment]:
        valid_values: Final = ", ".join(f'"{env.value}"' for env in Environment)
        raise ValueError(f"Invalid environment: {environment}. Please use one of the following instead: {valid_values}")

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Set LITELLM_ENVIRONMENT to exactly 'production', 'development', or 'staging' (lowercase)
  2. Unset it if you are fine with the 'development' default
  3. If your pipeline uses 'prod'/'dev', map it to the allowed value in your env templating before starting litellm

Example fix

# before
export LITELLM_ENVIRONMENT=prod

# after
export LITELLM_ENVIRONMENT=production
Defensive patterns

Strategy: validation

Validate before calling

import os

VALID = {"production", "development", "staging"}
env_name = os.getenv("LITELLM_ENVIRONMENT", "development")
assert env_name in VALID, f"LITELLM_ENVIRONMENT must be one of {VALID}, got {env_name!r}"

Type guard

def is_valid_litellm_environment(value: str) -> bool:
    return value in {"production", "development", "staging"}

Try / catch

try:
    DeepEvalLogger()
except ValueError as e:
    if "Invalid environment" in str(e):
        os.environ["LITELLM_ENVIRONMENT"] = "development"
        DeepEvalLogger()
    else:
        raise

Prevention

When it happens

Trigger: Setting LITELLM_ENVIRONMENT to a value outside {production, development, staging} — e.g. 'prod', 'dev', 'staging-eu', 'Production' (case-sensitive) — and then instantiating DeepEvalLogger.

Common situations: Teams already using LITELLM_ENVIRONMENT for their own deploy-stage conventions ('prod'/'dev') who then enable the DeepEval callback; values inherited from other tooling with different vocabularies.

Related errors


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