Skip to content

Azure URL Legacy Mode Not Appending URL #581

@TrevorLogan44

Description

@TrevorLogan44

I apologize if I'm misinterpreting, as I'm new to Azure. In the URL for my azure model, I'm having to include "openai/deployments/" in the baseUrl, as well as feed the api-version as an additional query parameter. Should setting the AzureUrlPathMode to LEGACY automate this process?

I'm using version 3.0.2.

This code reaches https://<my_azure_endpoint>/openai/deployments/gpt-4o/chat/completions?api-version=2024-06-01:

 // Configure the Azure OpenAI Client
    	String model = "gpt-4o";
        OpenAIClient client = OpenAIOkHttpClient.builder()
        		.baseUrl("<my_azure_endpoint>/openai/deployments/" + model)    // I don't feel like i should have to specify /openai/deployments/" + model here
        		.credential(AzureApiKeyCredential.create("<my_key>"))        		
        		.build();
        		
        ChatCompletionCreateParams createParams = ChatCompletionCreateParams.builder()
            .model(model) 
            .putAdditionalQueryParam("api-version","2024-06-01") // I don't feel like I should have to do this after setting it in the client
            .maxCompletionTokens(100) 
            .temperature(0)
            .addUserMessage("Hi!") 
            .build();

This code does not reach https://<my_azure_endpoint>/openai/deployments/gpt-4o/chat/completions?api-version=2024-06-01 :

        OpenAIClient client = OpenAIOkHttpClient.builder()
        		.baseUrl("<my_azure_endpoint>") 
        		.credential(AzureApiKeyCredential.create("<my_key>"))        		
        		.azureServiceVersion(AzureOpenAIServiceVersion.fromString("2024-06-01")) 
        		.azureUrlPathMode(AzureUrlPathMode.LEGACY) 
        		.build();
        		
        ChatCompletionCreateParams createParams = ChatCompletionCreateParams.builder()
            .model("gpt-4o") 
            .maxCompletionTokens(100) 
            .temperature(0)
            .addUserMessage("Hi!") 
            .build();

The resulting url from the debugger here is just https://<my_azure_endpoint>/chat/completions, not including the deployment or the version number.

Is this intended? my maven dependency for azure is:

<dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-core</artifactId>
    <version>1.55.4</version>
</dependency>

Could that be the issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requestedsdk

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions