From e4004cac0e23ede039f7297949b687e0106f1c36 Mon Sep 17 00:00:00 2001 From: Manuel Andreo Garcia Date: Wed, 12 Feb 2025 11:04:17 +0100 Subject: [PATCH] document AzureOpenAIClientBuilderCustomizer Signed-off-by: Manuel Andreo Garcia --- .../pages/api/chat/azure-openai-chat.adoc | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/azure-openai-chat.adoc b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/azure-openai-chat.adoc index d05145aae07..c66d22b62df 100644 --- a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/azure-openai-chat.adoc +++ b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/azure-openai-chat.adoc @@ -110,6 +110,29 @@ dependencies { TIP: Refer to the xref:getting-started.adoc#dependency-management[Dependency Management] section to add the Spring AI BOM to your build file. +The Azure OpenAI Chat Client is created using the link:https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/OpenAIClientBuilder.java[OpenAIClientBuilder] provided by the Azure SDK. Spring AI allows to customize the builder by providing link:https://github.com/spring-projects/spring-ai/blob/main/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/azure/openai/AzureOpenAIClientBuilderCustomizer.java[AzureOpenAIClientBuilderCustomizer] beans. + +A customizer might be used for example to change the default response timeout: + +[source,java] +---- +@Configuration +public class AzureOpenAiConfig { + + @Bean + public OpenAIClientBuilderCustomizer responseTimeoutCustomizer() { + return openAiClientBuilder -> { + HttpClientOptions clientOptions = new HttpClientOptions() + .setResponseTimeout(Duration.ofMinutes(5)); + openAiClientBuilder.httpClient(HttpClient.createDefault(clientOptions)); + }; + } + +} +---- + + + === Chat Properties The prefix `spring.ai.azure.openai` is the property prefix to configure the connection to Azure OpenAI.