home-assistant/core · error · UpdateFailed
api_error
Error message
api_error
What it means
An UpdateFailed raised with translation key 'api_error' when the Anthropic coordinator's models.list() call raises a generic anthropic.APIError (anything other than timeout or authentication: 400/403/429/5xx). The DataUpdateCoordinator catches it, marks the entity unavailable, and schedules the next poll.
Source
Thrown at homeassistant/components/anthropic/coordinator.py:99
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()
if self._listeners and not self.hass.is_stopping:
self._schedule_refresh()
@callback
def get_model_info(self, model_id: str) -> tuple[anthropic.types.ModelInfo, bool]:
"""Get model info for a given model ID."""View on GitHub (pinned to 58a3fdb3ea)
Solutions
- Check err.status_code via logs to distinguish 429 (slow down usage / raise rate limits) from 5xx (wait for recovery)
- Upgrade the anthropic package to a version pinned by Home Assistant core requirements
- If persistent 4xx, inspect the message placeholder for the API's explanation (bad model id, org issues)
Defensive patterns
Strategy: retry
Try / catch
try:
result = await self.client.models.list(timeout=10.0)
except anthropic.APITimeoutError as err:
raise TimeoutError(err.message or str(err)) from err
except anthropic.AuthenticationError as err:
raise ConfigEntryAuthFailed(...) from err
except anthropic.APIError as err:
raise UpdateFailed(...) from err Prevention
- Order exception handlers from specific (timeout, auth) to generic (APIError)
- Let the coordinator's backoff handle 429/5xx instead of manual retries
When it happens
Trigger: await self.client.models.list(timeout=10.0) raising anthropic.APIError: HTTP 429 rate limit, 500/529 overloaded Anthropic service, 400 bad request from a library/model mismatch, or 403 permission errors not classified as AuthenticationError.
Common situations: Rate limiting after heavy conversation agent usage, Anthropic capacity events (529 overloaded), or an anthropic package version whose request shape no longer matches the API.
Related errors
- err
- api_authentication_error
- Error communicating with API: {err}
- Error communicating with API: {err}
- Unable find multi-factor auth module: {mfa_module_id}
AI-assisted analysis of home-assistant/core@58a3fdb3ea (2026-08-14).
Data as JSON: /api/errors/3c07c0f8ddc45679.
Report an issue: GitHub.