diff --git a/openai/azure-openai/runtime/src/main/java/io/quarkiverse/langchain4j/azure/openai/runtime/AzureOpenAiRecorder.java b/openai/azure-openai/runtime/src/main/java/io/quarkiverse/langchain4j/azure/openai/runtime/AzureOpenAiRecorder.java index b19825979..ce93ef030 100644 --- a/openai/azure-openai/runtime/src/main/java/io/quarkiverse/langchain4j/azure/openai/runtime/AzureOpenAiRecorder.java +++ b/openai/azure-openai/runtime/src/main/java/io/quarkiverse/langchain4j/azure/openai/runtime/AzureOpenAiRecorder.java @@ -90,8 +90,11 @@ public Object get() { } private String getBaseUrl(Langchain4jAzureOpenAiConfig runtimeConfig) { - return String.format("https://%s.openai.azure.com/openai/deployments/%s", runtimeConfig.resourceName(), - runtimeConfig.deploymentId()); + var baseUrl = runtimeConfig.baseUrl(); + + return !baseUrl.trim().isEmpty() ? baseUrl + : String.format("https://%s.openai.azure.com/openai/deployments/%s", runtimeConfig.resourceName(), + runtimeConfig.deploymentId()); } public void cleanUp(ShutdownContext shutdown) { diff --git a/openai/azure-openai/runtime/src/main/java/io/quarkiverse/langchain4j/azure/openai/runtime/config/Langchain4jAzureOpenAiConfig.java b/openai/azure-openai/runtime/src/main/java/io/quarkiverse/langchain4j/azure/openai/runtime/config/Langchain4jAzureOpenAiConfig.java index a08f5877b..b3f180462 100644 --- a/openai/azure-openai/runtime/src/main/java/io/quarkiverse/langchain4j/azure/openai/runtime/config/Langchain4jAzureOpenAiConfig.java +++ b/openai/azure-openai/runtime/src/main/java/io/quarkiverse/langchain4j/azure/openai/runtime/config/Langchain4jAzureOpenAiConfig.java @@ -22,6 +22,13 @@ public interface Langchain4jAzureOpenAiConfig { */ String deploymentId(); + /** + * The base url for the Azure OpenAI resource. Defaults to + * {@code https://${quarkus.langchain4j.azure-openai.resource-name}.openai.azure.com/openai/deployments/${quarkus.langchain4j.azure-openai.deployment-id}}. + */ + @WithDefault("https://${quarkus.langchain4j.azure-openai.resource-name}.openai.azure.com/openai/deployments/${quarkus.langchain4j.azure-openai.deployment-id}") + String baseUrl(); + /** * The API version to use for this operation. This follows the YYYY-MM-DD format */