Azure / Azure/azure-sdk-for-python
[Bug] Custom Azure OpenAI deployments doesn't works with `azure.ai.inference` - ResourceNotFoundError (404)
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 3.4k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 193
Description
- **Package Name**: azure.ai.inference
- **Package Version**: 1.0.0b9
- **Operating System**: mac OS Sonama 14.5
- **Python Version**: 3.13, 3.12, 3.11, 3.10
**Describe the bug**
I am able to access the chat completion api from `AzureOpenAI` but not using `azure.ai.inference`
**To Reproduce**
Steps to reproduce the behavior:
1. create a virtual env
2. install the package using `pip install azure-ai-inference`
### With `from openai import AzureOpenAI` works!
```python
# sample code to connect to azure openai
import os
from openai import AzureOpenAI
API_KEY = os.getenv("AZURE_OPENAI_API_KEY")
API_VERSION = os.getenv("AZURE_OPENAI_API_VERSION")
AZURE_ENDPOINT = os.getenv("AZURE_OPENAI_ENDPOINT")
MODEL_NAME = os.getenv("AZURE_OPENAI_MODEL_NAME")
client = AzureOpenAI(
api_key=API_KEY,
api_version=API_VERSION,
azure_endpoint=AZURE_ENDPOINT,
)
response = client.chat.completions.create(
model=MODEL_NAME,
messages=[{"role": "user", "content": "Hello, world!"}],
)
print(response)
```
### With `from azure.ai.inference import ChatCompletionsClient` does not work
```
import os
from azure.ai.inference import ChatCompletionsClient
from azure.core.credentials import AzureKeyCredential
API_KEY = os.getenv("AZURE_OPENAI_API_KEY")
API_VERSION = os.getenv("AZURE_OPENAI_API_VERSION")
AZURE_ENDPOINT = os.getenv("AZURE_OPENAI_ENDPOINT")
MODEL_NAME = os.getenv("AZURE_OPENAI_MODEL_NAME")
client = ChatCompletionsClient(
endpoint=AZURE_ENDPOINT,
credential=AzureKeyCredential(API_KEY),
api_version=API_VERSION,
)
model_info = client.get_model_info()
print(model_info)
```
**Expected behavior**
Both needs to work as expected
**Error Message**
```sh
Traceback (most recent call last):
File "test.py", line 19, in
model_info = client.get_model_info()
^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.12/site-packages/azure/core/tracing/decorator.py", line 119, in wrapper_use_tracer
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.12/site-packages/azure/ai/inference/_patch.py", line 762, in get_model_info
raise error
File ".venv/lib/python3.12/site-packages/azure/ai/inference/_patch.py", line 759, in get_model_info
self._model_info = self._get_model_info(**kwargs) # pylint: disable=attribute-defined-outside-init
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.12/site-packages/azure/core/tracing/decorator.py", line 119, in wrapper_use_tracer
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.12/site-packages/azure/ai/inference/_operations/_operations.py", line 472, in _get_model_info
map_error(status_code=response.status_code, response=response, error_map=error_map)
File ".venv/lib/python3.12/site-packages/azure/core/exceptions.py", line 163, in map_error
raise error
azure.core.exceptions.ResourceNotFoundError: (404) Resource not found
Code: 404
Message: Resource not found
```
**Additional context**
-
Contributor guide
Assessment
This issue has not been assessed yet.