BerriAI/litellm · error · NotImplementedError

acreate_sandbox must be implemented by provider

Error message

acreate_sandbox must be implemented by provider

What it means

BaseSandboxConfig.acreate_sandbox() is a required async hook that every sandbox provider must implement to provision a code-execution container (returning a ContainerHandle). The base class raises NotImplementedError by design. Reaching it means sandbox creation was routed to the abstract base config rather than a concrete provider implementation (OpenSandbox, E2B, ...).

Source

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

    _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,
        **kwargs,
    ) -> CodeExecutionResult:
        raise NotImplementedError("arun_code must be implemented by provider")

    async def adelete_sandbox(
        self,
        *,
        container: ContainerHandle | str,
        api_key: str | None = None,
        **kwargs,
    ) -> bool:

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Point the sandbox call at a supported provider (OpenSandbox/E2B) so a concrete config is used.
  2. In a custom subclass, implement `async def acreate_sandbox(self, *, template=None, timeout=None, allow_internet_access=None, api_key=None, **kwargs) -> ContainerHandle` that calls your provider's container API.
  3. Verify your registration code passes the concrete config class, not BaseSandboxConfig, for the provider.

Example fix

# before
class MySandbox(BaseSandboxConfig):
    pass

# after
class MySandbox(BaseSandboxConfig):
    async def acreate_sandbox(self, *, template=None, timeout=None,
                              allow_internet_access=None, api_key=None, **kwargs) -> ContainerHandle:
        resp = await self._client.post("/containers", json={"template": template})
        resp.raise_for_status()
        return ContainerHandle(**resp.json())
Defensive patterns

Strategy: type-guard

Validate before calling

from litellm.llms.base_llm.sandbox.transformation import BaseSandboxConfig

assert type(cfg).acreate_sandbox is not BaseSandboxConfig.acreate_sandbox, "acreate_sandbox not implemented"

Type guard

import inspect
from litellm.llms.base_llm.sandbox.transformation import BaseSandboxConfig

def supports_create_sandbox(cfg: BaseSandboxConfig) -> bool:
    return type(cfg).acreate_sandbox is not BaseSandboxConfig.acreate_sandbox

Try / catch

try:
    handle = await cfg.acreate_sandbox(template="python")
except NotImplementedError:
    logger.error("provider %s does not support sandbox creation", type(cfg).__name__)
    raise

Prevention

When it happens

Trigger: Calling the sandbox-creation path (e.g. via litellm's code-execution/sandbox API) when the active provider config is BaseSandboxConfig or a custom subclass that does not override acreate_sandbox.

Common situations: Custom sandbox provider with an incomplete implementation; provider name not resolving to a concrete config; litellm version change that introduced the acreate_sandbox contract on existing custom subclasses.

Related errors


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