{"record":{"id":"3c07c0f8ddc45679","repo":"home-assistant/core","slug":"api-error-3c07c0","errorCode":null,"errorMessage":"api_error","messagePattern":"api_error","errorType":"exception","errorClass":"UpdateFailed","httpStatus":null,"severity":"error","filePath":"homeassistant/components/anthropic/coordinator.py","lineNumber":99,"sourceCode":"        self.update_interval = UPDATE_INTERVAL_CONNECTED\n        super().async_set_updated_data(data)\n\n    async def async_update_data(self) -> list[anthropic.types.ModelInfo]:\n        \"\"\"Fetch data from the API.\"\"\"\n        try:\n            self.update_interval = UPDATE_INTERVAL_DISCONNECTED\n            result = await self.client.models.list(timeout=10.0)\n            self.update_interval = UPDATE_INTERVAL_CONNECTED\n        except anthropic.APITimeoutError as err:\n            raise TimeoutError(err.message or str(err)) from err\n        except anthropic.AuthenticationError as err:\n            raise ConfigEntryAuthFailed(\n                translation_domain=DOMAIN,\n                translation_key=\"api_authentication_error\",\n                translation_placeholders={\"message\": err.message},\n            ) from err\n        except anthropic.APIError as err:\n            raise UpdateFailed(\n                translation_domain=DOMAIN,\n                translation_key=\"api_error\",\n                translation_placeholders={\"message\": err.message},\n            ) from err\n        return result.data\n\n    def mark_connection_error(self) -> None:\n        \"\"\"Mark the connection as having an error and reschedule background check.\"\"\"\n        self.update_interval = UPDATE_INTERVAL_DISCONNECTED\n        if self.last_update_success:\n            self.last_update_success = False\n            self.async_update_listeners()\n            if self._listeners and not self.hass.is_stopping:\n                self._schedule_refresh()\n\n    @callback\n    def get_model_info(self, model_id: str) -> tuple[anthropic.types.ModelInfo, bool]:\n        \"\"\"Get model info for a given model ID.\"\"\"","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/anthropic/coordinator.py#L81-L117","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    result = await self.client.models.list(timeout=10.0)\nexcept anthropic.APITimeoutError as err:\n    raise TimeoutError(err.message or str(err)) from err\nexcept anthropic.AuthenticationError as err:\n    raise ConfigEntryAuthFailed(...) from err\nexcept anthropic.APIError as err:\n    raise UpdateFailed(...) from err","preventionTips":["Order exception handlers from specific (timeout, auth) to generic (APIError)","Let the coordinator's backoff handle 429/5xx instead of manual retries"],"tags":["home-assistant","anthropic","api","rate-limit","coordinator"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}