{"record":{"id":"f7cb5d438bbc6abb","repo":"home-assistant/core","slug":"api-authentication-error-f7cb5d","errorCode":null,"errorMessage":"api_authentication_error","messagePattern":"api_authentication_error","errorType":"exception","errorClass":"HomeAssistantError","httpStatus":null,"severity":"critical","filePath":"homeassistant/components/anthropic/entity.py","lineNumber":1223,"sourceCode":"                new_messages, model_args[\"container\"] = _convert_content(\n                    [\n                        content\n                        async for content in chat_log.async_add_delta_content_stream(\n                            self.entity_id,\n                            AnthropicDeltaStream(\n                                chat_log,\n                                stream,\n                                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,","sourceCodeStart":1205,"sourceCodeEnd":1241,"githubUrl":"https://github.com/home-assistant/core/blob/58a3fdb3ea0538617f0a07efcfba6294de64fd59/homeassistant/components/anthropic/entity.py#L1205-L1241","documentation":"A HomeAssistantError with translation key 'api_authentication_error' raised in the conversation/entity path when the streaming messages.create call raises anthropic.AuthenticationError. Before raising, it triggers coordinator.async_request_refresh() so the coordinator independently confirms the auth failure and starts the reauth flow.","triggerScenarios":"Streaming a chat completion with an invalid API key (401): key revoked, replaced, or entered incorrectly; also possible after organization removal. The placeholder 'message' carries the API's error text.","commonSituations":"API key rotated in the Anthropic console after initial setup; billing lapse causing key deactivation; key pasted with whitespace/newline.","solutions":["Complete the reauth flow that the coordinator refresh triggers, entering a current API key","Validate the key independently via curl to the Anthropic models endpoint","Check the Anthropic console for key status and organization membership"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    async with client.messages.stream(**model_args) as stream:\n        ...\nexcept anthropic.AuthenticationError as err:\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","preventionTips":["Refresh the coordinator before raising so reauth starts from one code path","Rotate keys deliberately: update Home Assistant at the same time the key changes"],"tags":["home-assistant","anthropic","authentication","api-key"],"backgroundTag":null,"analyzedSha":"58a3fdb3ea0538617f0a07efcfba6294de64fd59","analyzedAt":"2026-08-14T20:54:38.818Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}