Thanks to visit codestin.com
Credit goes to github.com

Skip to content

AzureOpenAI().model.list() doesn't work when azure_deployment is specified #1397

Closed
@gabrielfu

Description

@gabrielfu

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

When using AzureOpenAI with azure_deployment specified and calling client.model.list(), the request fails with

openai.NotFoundError: Error code: 404 - {'error': {'code': '404', 'message': 'Resource not found'}}

Upon investigation, this is because the request url ended up being

https://my-resource.openai.azure.com/openai/deployments/my-deployment/models?api-version=2023-05-15

while the correct one should be

https://my-resource.openai.azure.com/openai/models?api-version=2023-05-15

To Reproduce

client = openai.AzureOpenAI(
    azure_endpoint=...,
    azure_deployment=...,
    api_key=...,
    api_version=...,
)
client.models.list()

Code snippets

No response

OS

macOS

Python version

Python v3.10.11

Library version

openai v1.26.0

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