{"record":{"id":"faeac66e3fc440e3","repo":"home-assistant/core","slug":"api-error-faeac6","errorCode":null,"errorMessage":"api_error","messagePattern":"api_error","errorType":"exception","errorClass":"HomeAssistantError","httpStatus":null,"severity":"error","filePath":"homeassistant/components/anthropic/entity.py","lineNumber":1231,"sourceCode":"                                output_tool=structure_name or None,\n                            ),\n                        )\n                    ]\n                )\n                cast(list[MessageParam], model_args[\"messages\"]).extend(new_messages)\n            except anthropic.AuthenticationError as err:\n                # Trigger coordinator to confirm the auth failure\n                # and trigger the reauth flow.\n                await coordinator.async_request_refresh()\n                raise HomeAssistantError(\n                    translation_domain=DOMAIN,\n                    translation_key=\"api_authentication_error\",\n                    translation_placeholders={\"message\": err.message},\n                ) from err\n            except anthropic.APIConnectionError as err:\n                LOGGER.info(\"Connection error while talking to Anthropic: %s\", err)\n                coordinator.mark_connection_error()\n                raise HomeAssistantError(\n                    translation_domain=DOMAIN,\n                    translation_key=\"api_error\",\n                    translation_placeholders={\"message\": err.message},\n                ) from err\n            except anthropic.AnthropicError as err:\n                # Non-connection error, mark connection as healthy\n                coordinator.async_set_updated_data(coordinator.data)\n                LOGGER.error(\"Error while talking to Anthropic: %s\", err)\n                raise HomeAssistantError(\n                    translation_domain=DOMAIN,\n                    translation_key=\"api_error\",\n                    translation_placeholders={\n                        \"message\": err.message\n                        if isinstance(err, anthropic.APIError)\n                        else str(err)\n                    },\n                ) from err\n","sourceCodeStart":1213,"sourceCodeEnd":1249,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/anthropic/entity.py#L1213-L1249","documentation":"A HomeAssistantError with translation key 'api_error' raised when the streaming chat call raises anthropic.APIConnectionError — the SDK could not reach Anthropic at all (DNS, TLS, refused connection). The handler logs at info level and calls coordinator.mark_connection_error() so the integration's connection state reflects the outage.","triggerScenarios":"messages.create with stream=True failing to connect: no internet, DNS failure for api.anthropic.com, firewall/proxy blocking egress, or TLS interception with an untrusted certificate.","commonSituations":"Local network outage, corporate proxy requiring allowlisting of api.anthropic.com, container deployments without DNS configured, self-signed MITM proxies.","solutions":["Verify egress to api.anthropic.com:443 (curl -I https://api.anthropic.com) from the Home Assistant host","Allowlist api.anthropic.com on firewalls/proxies and ensure the CA bundle trusts the presented certificate","Check DNS resolution inside containerized installs"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"import socket\n\ndef host_reachable(host: str = \"api.anthropic.com\", port: int = 443, timeout: float = 3.0) -> bool:\n    try:\n        with socket.create_connection((host, port), timeout=timeout):\n            return True\n    except OSError:\n        return False","typeGuard":"import anthropic\n\ndef is_connection_error(err: BaseException) -> bool:\n    return isinstance(err, anthropic.APIConnectionError)","tryCatchPattern":"except anthropic.APIConnectionError as err:\n    LOGGER.info(\"Connection error while talking to Anthropic: %s\", err)\n    coordinator.mark_connection_error()\n    raise HomeAssistantError(...) from err","preventionTips":["Allowlist api.anthropic.com:443 on firewalls and proxies","Mark the connection state before raising so UI reflects outage vs request failure"],"tags":["home-assistant","anthropic","network","connection"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}