BerriAI/litellm · error · NotImplementedError

validate_environment must be implemented by provider

Error message

validate_environment must be implemented by provider

What it means

Error "validate_environment must be implemented by provider" thrown in BerriAI/litellm.

Solutions

  1. Use a provider that implements the sandbox interface; validate_environment is abstract.
  2. Implement validate_environment in the custom sandbox provider's transformation class.
  3. Check the model/provider name routes to a supported sandbox provider.

When it happens

Trigger: Thrown at litellm/llms/base_llm/sandbox/transformation.py:50 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/f1ef64073c4f5150. Report an issue: GitHub.

Appendix: source

Thrown at litellm/llms/base_llm/sandbox/transformation.py:50

    """Passthrough of the sandbox's own execution output."""

    stdout: str = ""
    stderr: str = ""
    results: list[dict[str, Any]] = Field(default_factory=list)
    error: dict[str, Any] | None = None
    execution_count: int | None = None
    object: str = "code_execution"

    model_config = {"extra": "allow"}

    _hidden_params: dict = PrivateAttr(default_factory=dict)


class BaseSandboxConfig:
    """Provider-agnostic sandbox operations."""

    def validate_environment(self, api_key: str | None = None, **kwargs) -> str:
        raise NotImplementedError("validate_environment must be implemented by provider")

    async def acreate_sandbox(
        self,
        *,
        template: str | None = None,
        timeout: int | None = None,
        allow_internet_access: bool | None = None,
        api_key: str | None = None,
        **kwargs,
    ) -> ContainerHandle:
        raise NotImplementedError("acreate_sandbox must be implemented by provider")

    async def arun_code(
        self,
        *,
        container: ContainerHandle | str,
        code: str,
        api_key: str | None = None,

View on GitHub (pinned to 77b7c6c40c)