{"record":{"id":"eaa59b99f02b45d1","repo":"BerriAI/litellm","slug":"volcengine-api-key-is-required-set-ark-api-key","errorCode":null,"errorMessage":"Volcengine API key is required. Set ARK_API_KEY / VOLCENGINE_API_KEY or pass api_key.","messagePattern":"Volcengine API key is required\\. Set ARK_API_KEY / VOLCENGINE_API_KEY or pass api_key\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/volcengine/responses/transformation.py","lineNumber":115,"sourceCode":"\n    def validate_environment(self, headers: dict, model: str, litellm_params: GenericLiteLLMParams | None) -> dict:\n        \"\"\"\n        Build auth headers for Volcengine Responses API.\n        \"\"\"\n        if litellm_params is None:\n            litellm_params = GenericLiteLLMParams()\n        elif isinstance(litellm_params, dict):\n            litellm_params = GenericLiteLLMParams.model_validate(litellm_params)\n\n        api_key: Final = (\n            litellm_params.api_key\n            or litellm.api_key\n            or get_secret_str(\"ARK_API_KEY\")\n            or get_secret_str(\"VOLCENGINE_API_KEY\")\n        )\n\n        if api_key is None:\n            raise ValueError(\"Volcengine API key is required. Set ARK_API_KEY / VOLCENGINE_API_KEY or pass api_key.\")\n\n        return get_volcengine_headers(api_key=api_key, extra_headers=headers)\n\n    def get_complete_url(\n        self,\n        api_base: str | None,\n        litellm_params: dict,\n    ) -> str:\n        \"\"\"\n        Construct Volcengine Responses API endpoint.\n        \"\"\"\n        base_url = (\n            api_base\n            or litellm.api_base\n            or get_secret_str(\"VOLCENGINE_API_BASE\")\n            or get_secret_str(\"ARK_API_BASE\")\n            or get_volcengine_base_url()\n        )","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/volcengine/responses/transformation.py#L97-L133","documentation":"The Volcengine Responses API config resolves the key from litellm_params.api_key, then litellm.api_key, then the secrets ARK_API_KEY and VOLCENGINE_API_KEY. If the whole chain is empty, this ValueError is raised while building request headers - the call never reaches the network.","triggerScenarios":"litellm.responses(model=\"volcengine/...\", input=\"hi\") with no api_key argument and neither ARK_API_KEY nor VOLCENGINE_API_KEY in the environment; proxy deployments where the volcengine model entry lacks an api_key in litellm_params.","commonSituations":"Testing the newer Responses API surface on a machine configured only for the chat completions path; env var present in one shell but the app runs under systemd/PMF with a clean env; key stored under a differently-named var.","solutions":["Pass api_key explicitly to the responses call.","Export ARK_API_KEY (preferred) or VOLCENGINE_API_KEY in the process environment.","In proxy config.yaml, add api_key to the model's litellm_params.","Set it globally: litellm.api_key = ... (checked second in the chain)."],"exampleFix":"# before\nresp = litellm.responses(model=\"volcengine/doubao-seed-1-6\", input=\"hello\")\n# -> ValueError: Volcengine API key is required...\n\n# after\nresp = litellm.responses(\n    model=\"volcengine/doubao-seed-1-6\",\n    input=\"hello\",\n    api_key=os.environ[\"ARK_API_KEY\"],\n)","handlingStrategy":"validation","validationCode":"import os\n\napi_key = kwargs.get(\"api_key\") or litellm.api_key or os.getenv(\"ARK_API_KEY\") or os.getenv(\"VOLCENGINE_API_KEY\")\nif not api_key:\n    raise RuntimeError(\"Volcengine Responses API needs api_key or ARK_API_KEY/VOLCENGINE_API_KEY\")\nresp = litellm.responses(model=\"volcengine/...\", input=\"hi\", api_key=api_key)","typeGuard":"const hasVolcengineKey = (cfg: {apiKey?: string; arkApiKey?: string; volcengineApiKey?: string}): boolean =>\n  Boolean(cfg.apiKey ?? cfg.arkApiKey ?? cfg.volcengineApiKey);","tryCatchPattern":"try:\n    resp = litellm.responses(model=\"volcengine/...\", input=\"hi\")\nexcept ValueError as e:\n    if \"Volcengine API key is required\" in str(e):\n        raise RuntimeError(\"Missing ARK_API_KEY/VOLCENGINE_API_KEY - check deployment env\") from e\n    raise","preventionTips":["Set ARK_API_KEY once at process start rather than relying on per-call arguments.","In the LiteLLM proxy, store api_key in the model entry so routes never depend on shell env.","Add a config sanity check that fails the healthcheck when the key is absent."],"tags":["volcengine","responses-api","api-key","authentication","environment-variable","litellm"],"backgroundTag":"missing-api-key","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}