From b171bb8c80a5b94ce9c4763bfc5bd8463db4eabe Mon Sep 17 00:00:00 2001 From: Denis Shulyaka Date: Thu, 10 Sep 2026 08:04:04 +0300 Subject: [PATCH] Use OpenAPI 3.1.0 format for Anthropic JSON schemas (#181803) --- homeassistant/components/anthropic/config_flow.py | 2 +- homeassistant/components/anthropic/entity.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/anthropic/config_flow.py b/homeassistant/components/anthropic/config_flow.py index 7fc8e70c962a..7baecd07347f 100644 --- a/homeassistant/components/anthropic/config_flow.py +++ b/homeassistant/components/anthropic/config_flow.py @@ -577,7 +577,7 @@ class ConversationSubentryFlowHandler(ConfigSubentryFlow): "format": { "type": "json_schema", "schema": { - **to_openapi(location_schema), + **to_openapi(location_schema, openapi_version="3.1.0"), "additionalProperties": False, }, } diff --git a/homeassistant/components/anthropic/entity.py b/homeassistant/components/anthropic/entity.py index e62a2122bb4e..7f079e17c989 100644 --- a/homeassistant/components/anthropic/entity.py +++ b/homeassistant/components/anthropic/entity.py @@ -150,7 +150,9 @@ def _format_tool( ) -> ToolParam: """Format tool specification.""" unsupported_keys = {"oneOf", "anyOf", "allOf"} - schema = to_openapi(tool.parameters, custom_serializer=custom_serializer) + schema = to_openapi( + tool.parameters, custom_serializer=custom_serializer, openapi_version="3.1.0" + ) schema = {k: v for k, v in schema.items() if k not in unsupported_keys} return ToolParam( @@ -1114,6 +1116,7 @@ class AnthropicBaseLLMEntity(CoordinatorEntity[AnthropicCoordinator]): custom_serializer=chat_log.llm_api.custom_serializer if chat_log.llm_api else llm.selector_serializer, + openapi_version="3.1.0", ), "additionalProperties": False, }, @@ -1162,6 +1165,7 @@ class AnthropicBaseLLMEntity(CoordinatorEntity[AnthropicCoordinator]): custom_serializer=chat_log.llm_api.custom_serializer if chat_log.llm_api else llm.selector_serializer, + openapi_version="3.1.0", ), ) )