{"record":{"id":"560b5801846db516","repo":"BerriAI/litellm","slug":"api-key-is-required-for-volcengine-authentication","errorCode":null,"errorMessage":"api_key is required for Volcengine authentication","messagePattern":"api_key is required for Volcengine authentication","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/volcengine/embedding/transformation.py","lineNumber":196,"sourceCode":"            transformed_response[\"id\"] = response_json[\"id\"]\n\n        # Create EmbeddingResponse from transformed data\n        return EmbeddingResponse(**transformed_response)\n\n    def validate_environment(\n        self,\n        headers: dict,\n        model: str,\n        messages: list[AllMessageValues],\n        optional_params: dict,\n        litellm_params: dict,\n        api_key: str | None = None,\n        api_base: str | None = None,\n    ) -> dict:\n        \"\"\"Validate environment and return headers\"\"\"\n        # Get Volcengine headers\n        if api_key is None:\n            raise ValueError(\"api_key is required for Volcengine authentication\")\n        volcengine_headers: Final = get_volcengine_headers(api_key)\n        return {**headers, **volcengine_headers}\n\n    def get_error_class(self, error_message: str, status_code: int, headers: dict | httpx.Headers) -> BaseLLMException:\n        \"\"\"Get error class for Volcengine errors\"\"\"\n        from ..common_utils import VolcEngineError\n\n        # Convert dict to httpx.Headers if needed\n        if isinstance(headers, dict):\n            headers = httpx.Headers(headers)\n        return VolcEngineError(\n            status_code=status_code,\n            message=error_message,\n            headers=headers,\n        )\n","sourceCodeStart":178,"sourceCodeEnd":212,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/volcengine/embedding/transformation.py#L178-L212","documentation":"VolcEngineEmbeddingConfig.validate_environment builds the Authorization headers for the Ark embedding call via get_volcengine_headers(api_key). If the api_key argument is None at that point (no key resolved from call kwargs, litellm_params, or the ARK_API_KEY/VOLCENGINE_API_KEY environment chain), it raises this ValueError before any request is sent.","triggerScenarios":"litellm.embedding(model=\"volcengine/...\", input=[...]) in a shell/container where neither api_key nor ARK_API_KEY/VOLCENGINE_API_KEY is set; a typo'd env var name (e.g. VOLC_ENGINE_API_KEY); the key set in a .env file that the process never loaded.","commonSituations":"Local runs where the key lives only in the deploy environment; Docker/CI containers missing the env var; rotating keys and leaving the old var deleted; multi-provider code that sets keys per provider and misses Volcengine.","solutions":["Set the environment variable: export ARK_API_KEY=... (or VOLCENGINE_API_KEY).","Or pass it explicitly: litellm.embedding(model=\"volcengine/...\", input=[...], api_key=...).","If using a .env file, load it before importing/invoking litellm (from dotenv import load_dotenv; load_dotenv()).","In the LiteLLM proxy, define api_key in the model_list entry's litellm_params for the volcengine model."],"exampleFix":"# before\nresp = litellm.embedding(model=\"volcengine/ep-20240903144444\", input=[\"hi\"])\n# -> ValueError: api_key is required for Volcengine authentication\n\n# after\nimport os\nos.environ[\"ARK_API_KEY\"] = \"<your-ark-key>\"\n# or inline:\nresp = litellm.embedding(\n    model=\"volcengine/ep-20240903144444\",\n    input=[\"hi\"],\n    api_key=\"<your-ark-key>\",\n)","handlingStrategy":"validation","validationCode":"import os\n\nVOLC_KEY = os.getenv(\"ARK_API_KEY\") or os.getenv(\"VOLCENGINE_API_KEY\")\nif not VOLC_KEY:\n    raise RuntimeError(\"Set ARK_API_KEY (or VOLCENGINE_API_KEY) before embedding\")\nresp = litellm.embedding(model=\"volcengine/ep-...\", input=inputs, api_key=VOLC_KEY)","typeGuard":"const hasVolcengineKey = (env: Record<string, string | undefined>): boolean =>\n  Boolean(env.ARK_API_KEY ?? env.VOLCENGINE_API_KEY);","tryCatchPattern":"try:\n    resp = litellm.embedding(model=\"volcengine/ep-...\", input=inputs)\nexcept ValueError as e:\n    if \"api_key is required for Volcengine\" in str(e):\n        raise RuntimeError(\"Configure ARK_API_KEY in the deployment environment\") from e\n    raise","preventionTips":["Export ARK_API_KEY in every environment that runs Volcengine calls (local, CI, prod).","Pass api_key explicitly when multiple Ark accounts are in play.","Add the secret to the platform secret store and map it to ARK_API_KEY at startup."],"tags":["volcengine","embedding","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"}