home-assistant/core · critical · ConfigEntryAuthFailed
api_authentication_error
Error message
api_authentication_error
What it means
A ConfigEntryAuthFailed raised with translation key 'api_authentication_error' when the periodic client.models.list() call in the Anthropic coordinator raises anthropic.AuthenticationError. It signals the API key is no longer valid and starts Home Assistant's reauth flow for the config entry.
Source
Thrown at homeassistant/components/anthropic/coordinator.py:93
)
@callback
@override
def async_set_updated_data(self, data: list[anthropic.types.ModelInfo]) -> None:
"""Manually update data, notify listeners and update refresh interval."""
self.update_interval = UPDATE_INTERVAL_CONNECTED
super().async_set_updated_data(data)
async def async_update_data(self) -> list[anthropic.types.ModelInfo]:
"""Fetch data from the API."""
try:
self.update_interval = UPDATE_INTERVAL_DISCONNECTED
result = await self.client.models.list(timeout=10.0)
self.update_interval = UPDATE_INTERVAL_CONNECTED
except anthropic.APITimeoutError as err:
raise TimeoutError(err.message or str(err)) from err
except anthropic.AuthenticationError as err:
raise ConfigEntryAuthFailed(
translation_domain=DOMAIN,
translation_key="api_authentication_error",
translation_placeholders={"message": err.message},
) from err
except anthropic.APIError as err:
raise UpdateFailed(
translation_domain=DOMAIN,
translation_key="api_error",
translation_placeholders={"message": err.message},
) from err
return result.data
def mark_connection_error(self) -> None:
"""Mark the connection as having an error and reschedule background check."""
self.update_interval = UPDATE_INTERVAL_DISCONNECTED
if self.last_update_success:
self.last_update_success = False
self.async_update_listeners()View on GitHub (pinned to 58a3fdb3ea)
Solutions
- Follow the reauth flow that Home Assistant opens and paste a currently valid Anthropic API key
- Verify the key with a direct curl to https://api.anthropic.com/v1/models using x-api-key
- Check the Anthropic console for revoked keys or organization membership changes
Defensive patterns
Strategy: try-catch
Validate before calling
import anthropic
async def key_valid(client: anthropic.AsyncAnthropic) -> bool:
try:
await client.models.list(timeout=10.0)
return True
except anthropic.AuthenticationError:
return False Type guard
import anthropic
def is_auth_error(err: BaseException) -> bool:
return isinstance(err, anthropic.AuthenticationError) Try / catch
try:
result = await self.client.models.list(timeout=10.0)
except anthropic.AuthenticationError as err:
raise ConfigEntryAuthFailed(
translation_domain=DOMAIN,
translation_key="api_authentication_error",
translation_placeholders={"message": err.message},
) from err Prevention
- Validate the API key once at config flow time with a cheap models.list call
- Store the key via Home Assistant secrets rather than pasting it repeatedly
When it happens
Trigger: await self.client.models.list(timeout=10.0) returning a 401 from the Anthropic API — revoked/rotated API key, wrong key entered in the config flow, or a key from an organization the user no longer belongs to.
Common situations: User regenerated the API key in the Anthropic console but did not update Home Assistant; key revoked for policy/billing reasons; typo or whitespace when pasting the key initially.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- api_authentication_error
- api_error
- invalid_api_key
- Authentication failed: {reauth_err}
- coordinator_auth_error
AI-assisted analysis of home-assistant/core@58a3fdb3ea (2026-08-14).
Data as JSON: /api/errors/6eb2fa5bba48450f.
Report an issue: GitHub.