BerriAI/litellm · error · GetAPIKeyError

API key response missing token

Error message

API key response missing token

What it means

Error "API key response missing token" thrown in BerriAI/litellm.

Solutions

  1. The Copilot token response lacked a token; re-authenticate via the OAuth Device Flow and ensure your GitHub account has an active Copilot subscription.

When it happens

Trigger: Thrown at litellm/llms/github_copilot/authenticator.py:115 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/1f37f4343fc5e293. Report an issue: GitHub.

Appendix: source

Thrown at litellm/llms/github_copilot/authenticator.py:115

                        message="API key expired",
                        status_code=401,
                    )
        except OSError:
            verbose_logger.warning("No API key file found or error opening file")
        except (json.JSONDecodeError, KeyError) as e:
            verbose_logger.warning("Error reading API key from file: %s", e)
        except APIKeyExpiredError:
            pass  # Already logged in the try block

        try:
            api_key_info = self._refresh_api_key()
            with open(self.api_key_file, "w") as f:
                json.dump(api_key_info, f)
            token: Final = api_key_info.get("token")
            if token:
                return token
            else:
                raise GetAPIKeyError(
                    message="API key response missing token",
                    status_code=401,
                )
        except OSError as e:
            verbose_logger.error("Error saving API key to file: %s", e)
            raise GetAPIKeyError(
                message=f"Failed to save API key: {e}",
                status_code=500,
            )
        except RefreshAPIKeyError as e:
            raise GetAPIKeyError(
                message=f"Failed to refresh API key: {e}",
                status_code=401,
            )

    def get_api_base(self) -> str | None:
        """
        Get the API endpoint from the api-key.json file.

View on GitHub (pinned to 77b7c6c40c)