Skip to content

Azure Endpoint URL is not Trailing-Slash Agnostic #1894

@Jozef833

Description

@Jozef833

Confirm this is an issue with the Python library and not an underlying OpenAI API

  • This is an issue with the Python library

Describe the bug

In src/openai/lib/azure.py, there are four cases where the endpoint URL is simply concatenated like:

f"{azure_endpoint}/openai/deployments/{azure_deployment}"
or
f"{azure_endpoint}/openai"

If azure_endpoint has a trailing forward slash (which many comments in the code suggest is allowed, as well as an example in the repository), it will have // in the URL, which is wrong.

To make it agnostic, it should be:

f"{azure_endpoint.rstrip("/")}/openai/deployments/{azure_deployment}"
and
f"{azure_endpoint.rstrip("/")}/openai"

This would be sufficient to fix it: #1893 673a496

To Reproduce

  1. Initialize an AsyncAzureOpenAI client.
  2. Await on client.chat.completions.with_raw_response.create(**model_args).
  3. The error code will be 404 Resource not found because the URL is not properly formatted.

Code snippets

No response

OS

Windows 10

Python version

Python 3.12.4

Library version

openai v1.6.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions