{"record":{"id":"eead9be5e10ec95b","repo":"BerriAI/litellm","slug":"acreate-sandbox-must-be-implemented-by-provider","errorCode":null,"errorMessage":"acreate_sandbox must be implemented by provider","messagePattern":"acreate_sandbox must be implemented by provider","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"litellm/llms/base_llm/sandbox/transformation.py","lineNumber":61,"sourceCode":"    _hidden_params: dict = PrivateAttr(default_factory=dict)\n\n\nclass BaseSandboxConfig:\n    \"\"\"Provider-agnostic sandbox operations.\"\"\"\n\n    def validate_environment(self, api_key: str | None = None, **kwargs) -> str:\n        raise NotImplementedError(\"validate_environment must be implemented by provider\")\n\n    async def acreate_sandbox(\n        self,\n        *,\n        template: str | None = None,\n        timeout: int | None = None,\n        allow_internet_access: bool | None = None,\n        api_key: str | None = None,\n        **kwargs,\n    ) -> ContainerHandle:\n        raise NotImplementedError(\"acreate_sandbox must be implemented by provider\")\n\n    async def arun_code(\n        self,\n        *,\n        container: ContainerHandle | str,\n        code: str,\n        api_key: str | None = None,\n        **kwargs,\n    ) -> CodeExecutionResult:\n        raise NotImplementedError(\"arun_code must be implemented by provider\")\n\n    async def adelete_sandbox(\n        self,\n        *,\n        container: ContainerHandle | str,\n        api_key: str | None = None,\n        **kwargs,\n    ) -> bool:","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/base_llm/sandbox/transformation.py#L43-L79","documentation":"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, ...).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Point the sandbox call at a supported provider (OpenSandbox/E2B) so a concrete config is used.","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.","Verify your registration code passes the concrete config class, not BaseSandboxConfig, for the provider."],"exampleFix":"# before\nclass MySandbox(BaseSandboxConfig):\n    pass\n\n# after\nclass MySandbox(BaseSandboxConfig):\n    async def acreate_sandbox(self, *, template=None, timeout=None,\n                              allow_internet_access=None, api_key=None, **kwargs) -> ContainerHandle:\n        resp = await self._client.post(\"/containers\", json={\"template\": template})\n        resp.raise_for_status()\n        return ContainerHandle(**resp.json())","handlingStrategy":"type-guard","validationCode":"from litellm.llms.base_llm.sandbox.transformation import BaseSandboxConfig\n\nassert type(cfg).acreate_sandbox is not BaseSandboxConfig.acreate_sandbox, \"acreate_sandbox not implemented\"","typeGuard":"import inspect\nfrom litellm.llms.base_llm.sandbox.transformation import BaseSandboxConfig\n\ndef supports_create_sandbox(cfg: BaseSandboxConfig) -> bool:\n    return type(cfg).acreate_sandbox is not BaseSandboxConfig.acreate_sandbox","tryCatchPattern":"try:\n    handle = await cfg.acreate_sandbox(template=\"python\")\nexcept NotImplementedError:\n    logger.error(\"provider %s does not support sandbox creation\", type(cfg).__name__)\n    raise","preventionTips":["Prefer built-in providers (OpenSandbox, E2B) over hand-rolled sandbox configs.","Feature-check provider configs at startup, not per request.","Keep custom sandbox implementations in one module covered by interface-conformance tests."],"tags":["sandbox","not-implemented","async","litellm"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}