{"record":{"id":"6d202128bde39a8e","repo":"BerriAI/litellm","slug":"opensandbox-api-base-is-required-pass-api-base-or","errorCode":null,"errorMessage":"OpenSandbox api_base is required. Pass api_base or set {OPEN_SANDBOX_API_BASE_ENV_VAR}.","messagePattern":"OpenSandbox api_base is required\\. Pass api_base or set (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/opensandbox/sandbox/transformation.py","lineNumber":412,"sourceCode":"        if not isinstance(data, dict):\n            return None\n        status: Final = data.get(\"status\")\n        if not isinstance(status, dict):\n            return None\n        state: Final = status.get(\"state\")\n        return str(state) if state is not None else None\n\n    @staticmethod\n    def _as_str_dict(value: object) -> dict[str, str]:\n        if not isinstance(value, dict):\n            return {}\n        return {str(k): str(v) for k, v in value.items()}\n\n    @staticmethod\n    def _api_base(api_base: str | None) -> str:\n        base: Final = api_base or get_secret_str(OPEN_SANDBOX_API_BASE_ENV_VAR)\n        if not base:\n            raise ValueError(f\"OpenSandbox api_base is required. Pass api_base or set {OPEN_SANDBOX_API_BASE_ENV_VAR}.\")\n        return str(base).rstrip(\"/\")\n\n    @staticmethod\n    def _lifecycle_headers(api_key: str) -> dict[str, str]:\n        headers: Final = {\"Content-Type\": \"application/json\"}\n        if api_key:\n            headers[\"OPEN-SANDBOX-API-KEY\"] = api_key\n        return headers\n\n    @staticmethod\n    def _endpoint_base_url(endpoint: str, api_base: str) -> str:\n        normalized_endpoint: Final = endpoint.rstrip(\"/\")\n        if normalized_endpoint.startswith((\"http://\", \"https://\")):\n            return normalized_endpoint\n        protocol: Final = api_base.split(\"://\", 1)[0] if \"://\" in api_base else \"http\"\n        return f\"{protocol}://{normalized_endpoint}\"\n\n    @staticmethod","sourceCodeStart":394,"sourceCodeEnd":430,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/opensandbox/sandbox/transformation.py#L394-L430","documentation":"Every OpenSandbox lifecycle call (create, wait, exec) needs the control-plane base URL. The static helper _api_base() falls back from the explicit api_base argument to the OPEN_SANDBOX_API_BASE environment variable; when both are absent it raises this ValueError before any network I/O happens.","triggerScenarios":"Invoking litellm's OpenSandbox provider (sandbox creation or code execution) without passing api_base and without OPEN_SANDBOX_API_BASE exported in the running process.","commonSituations":"Env var set in a dev shell but not in the container/serverless environment; variable name typo; assuming litellm ships a default OpenSandbox endpoint (it does not for lifecycle calls).","solutions":["export OPEN_SANDBOX_API_BASE=https://<your-opensandbox-host> in the process environment","Pass api_base explicitly on the call or in the litellm deployment config","Add a startup assertion that the variable resolves to catch this before traffic"],"exampleFix":"// before\nresult = litellm.opensandbox_create(...)  # no api_base anywhere\n\n// after\nimport os\nresult = litellm.opensandbox_create(..., api_base=os.environ[\"OPEN_SANDBOX_API_BASE\"])","handlingStrategy":"validation","validationCode":"import os\n\ndef opensandbox_configured() -> bool:\n    return bool(os.getenv(\"OPEN_SANDBOX_API_BASE\"))\n\nassert opensandbox_configured(), \"Set OPEN_SANDBOX_API_BASE or pass api_base\"  # run at startup","typeGuard":null,"tryCatchPattern":"try/except ValueError at the OpenSandbox call boundary can translate this deterministic config failure into a startup-time configuration error message for operators.","preventionTips":["Assert OPEN_SANDBOX_API_BASE resolves at process start","Keep sandbox configuration in one place instead of relying on ambient env per call","Include env-var presence checks in deployment smoke tests"],"tags":["opensandbox","env-var","configuration","litellm"],"backgroundTag":"missing-env-var","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}