Skip to content

[Azure Support] Azure OpenAI Authentication fails due to incorrect URL construction #459

@ch3ck

Description

@ch3ck

Description

The Azure OpenAI integration in the Go SDK fails to authenticate properly because it constructs incorrect API URLs that don't match the Azure OpenAI REST API specification.

Expected Behavior

Azure OpenAI API calls should use the correct URL format:

https://{endpoint}/openai/deployments/{deployment-id}/{operation}?api-version={version}

Actual Behavior

The current implementation incorrectly adds /openai/ prefix to the base endpoint and fails to properly construct deployment URLs, resulting in authentication errors.

POST https://{resource-name}.openai.azure.com/openai/chat/completions?api-version={api-version}

leads to:

404 Not found
{
   "code": "404",
    "message": "Resource not found"
}

Even when the deployment exists and is configured correctly in Azure.

Steps to Reproduce

  1. Configure Azure OpenAI client with azure.WithEndpoint() and azure.WithAPIKey()
  2. Make any API call (e.g., chat completions)
  3. Observe authentication failure due to malformed URLs

Environment

  • Go SDK version: Latest
  • Azure OpenAI API version: 2024-10-21
  • Authentication method: API Key or Token Credential

Root Cause

The issue is in azure/azure.go where:

  • Base URL incorrectly includes /openai/ prefix
  • Path construction logic doesn't properly format deployment URLs
  • Route mappings include incorrect path prefixes

Impact

This prevents the Azure OpenAI integration from working correctly, blocking users from connecting to Azure OpenAI services.

Reference

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions