{"record":{"id":"31ca35a44cd45ae3","repo":"BerriAI/litellm","slug":"gigachat-credentials-not-provided-set-gigachat-cr","errorCode":null,"errorMessage":"GigaChat credentials not provided. Set GIGACHAT_CREDENTIALS or GIGACHAT_API_KEY environment variable.","messagePattern":"GigaChat credentials not provided\\. Set GIGACHAT_CREDENTIALS or GIGACHAT_API_KEY environment variable\\.","errorType":"exception","errorClass":"GigaChatAuthError","httpStatus":401,"severity":"error","filePath":"litellm/llms/gigachat/authenticator.py","lineNumber":83,"sourceCode":"    auth_url: str | None = None,\n) -> str:\n    \"\"\"\n    Get valid access token, using cache if available.\n\n    Args:\n        credentials: Base64-encoded credentials (client_id:client_secret)\n        scope: API scope (GIGACHAT_API_PERS, GIGACHAT_API_CORP, etc.)\n        auth_url: OAuth endpoint URL\n\n    Returns:\n        Access token string\n\n    Raises:\n        GigaChatAuthError: If authentication fails\n    \"\"\"\n    credentials = credentials or _get_credentials()\n    if not credentials:\n        raise GigaChatAuthError(\n            status_code=401,\n            message=\"GigaChat credentials not provided. Set GIGACHAT_CREDENTIALS or GIGACHAT_API_KEY environment variable.\",\n        )\n\n    scope = scope or _get_scope()\n    auth_url = auth_url or _get_auth_url()\n\n    # Check cache\n    cache_key: Final = f\"gigachat_token:{credentials[:16]}\"\n    cached: Final = _token_cache.get_cache(cache_key)\n    if cached:\n        token, expires_at = cached\n        # Check if token is still valid (with buffer)\n        if time.time() * 1000 < expires_at - TOKEN_EXPIRY_BUFFER_MS:\n            verbose_logger.debug(\"Using cached GigaChat access token\")\n            return token\n\n    # Request new token","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/gigachat/authenticator.py#L65-L101","documentation":"GigaChatAuthError (a LiteLLM BaseLLMException with status_code 401) raised by the synchronous get_access_token when no credentials can be resolved. The resolver checks the explicit 'credentials' argument, then the GIGACHAT_CREDENTIALS and GIGACHAT_API_KEY secrets via LiteLLM's secret manager (environment or configured secret backend); all empty means OAuth cannot even start.","triggerScenarios":"litellm.completion(model='gigachat/...', messages=[...]) (or embedding/file helpers) on a machine where neither GIGACHAT_CREDENTIALS nor GIGACHAT_API_KEY is set and no api_key was passed — fresh checkout, new container, or CI runner without the secret.","commonSituations":"Forgot to export the env var; .env file not loaded in Docker/systemd/CI; secret named differently (e.g. GIGACHAT_TOKEN); deployed proxy missing the GIGACHAT_API_KEY environment value; assuming litellm.api_key covers GigaChat.","solutions":["Set GIGACHAT_CREDENTIALS to the Base64 of client_id:client_secret obtained from the GigaChat developer portal: export GIGACHAT_CREDENTIALS=$(printf 'id:secret' | base64).","Or set GIGACHAT_API_KEY if you use the simpler key form — the resolver accepts either.","Or pass credentials per call: litellm.completion(model='gigachat/...', api_key=<base64 credentials>, ...) — the GigaChat chat transformer forwards api_key as credentials.","In litellm proxy deployments, add the key to the environment/config of the proxy process and restart it."],"exampleFix":"# before\nimport litellm\nresp = litellm.completion(model=\"gigachat/GigaChat-2\", messages=[{\"role\": \"user\", \"content\": \"hi\"}])\n# GigaChatAuthError: credentials not provided\n\n# after\nimport base64, os\nos.environ[\"GIGACHAT_CREDENTIALS\"] = base64.b64encode(\n    b\"<client_id>:<client_secret>\"\n).decode()\nresp = litellm.completion(model=\"gigachat/GigaChat-2\", messages=[{\"role\": \"user\", \"content\": \"hi\"}])","handlingStrategy":"validation","validationCode":"import os\n\n\ndef gigachat_credentials_present() -> bool:\n    \"\"\"Check before the first litellm.completion('gigachat/...') call.\"\"\"\n    return bool(\n        os.environ.get(\"GIGACHAT_CREDENTIALS\") or os.environ.get(\"GIGACHAT_API_KEY\")\n    )\n\n\nassert gigachat_credentials_present(), (\n    \"Set GIGACHAT_CREDENTIALS (base64 client_id:client_secret) or GIGACHAT_API_KEY\"\n)","typeGuard":"def is_gigachat_model(model: str) -> bool:\n    return model.lower().startswith(\"gigachat/\")","tryCatchPattern":"from litellm.llms.gigachat.authenticator import GigaChatAuthError\n\ntry:\n    resp = litellm.completion(model=\"gigachat/GigaChat-2\", messages=msgs)\nexcept GigaChatAuthError as e:\n    if e.status_code == 401 and \"not provided\" in str(e):\n        raise RuntimeError(\"GigaChat credentials missing: set GIGACHAT_CREDENTIALS\") from e\n    raise","preventionTips":["Put GIGACHAT_CREDENTIALS/GIGACHAT_API_KEY in the process environment at startup and fail fast if absent.","Load .env files explicitly in containers/CI (docker-compose env_file, GitHub Actions secrets -> env).","Pass api_key per call when running multi-tenant setups so env leakage cannot break auth.","Distinguish this missing-credentials 401 from token-endpoint 401s (wrong client secret) by the message text."],"tags":["gigachat","oauth","credentials","authentication","env-var","sberbank"],"backgroundTag":"missing-api-key","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}