Azure / Azure/azure-sdk-for-python

Error "Model {modelName} is enabled only for api versions 2024-12-01-preview and later" when using o3-mini model with azure-ai-inference

Open
#40,759 1 comment 0 reactions 1 assignee Claimed by @trangevi View on GitHub
AI Model Inference Client customer-reported needs-team-attention question Service Attention
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
- **Python Version**: 3.11

**Describe the bug**
When attempting to use the o3-mini model with ChatCompletionsClient, an error occurs:
```bash
Traceback (most recent call last):
File "/workspaces/testaiinference/main.py", line 13, in
response = client.complete(
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/azure/ai/inference/_patch.py", line 738, in complete
raise HttpResponseError(response=response)
Error: (BadRequest) Model {modelName} is enabled only for api versions 2024-12-01-preview and later
Code: BadRequest
Message: Model {modelName} is enabled only for api versions 2024-12-01-preview and later
```

When calling the API using the api version `2024-12-01-preview`, the error is presented:
```bash
Traceback (most recent call last):
File "/workspaces/testaiinference/main.py", line 13, in
response = client.complete(
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/azure/ai/inference/_patch.py", line 737, in complete
map_error(status_code=response.status_code, response=response, error_map=error_map)
File "/usr/local/lib/python3.11/site-packages/azure/core/exceptions.py", line 163, in map_error
raise error
Error: (404) Resource not found
Code: 404
Message: Resource not found
```

**To Reproduce**
Steps to reproduce the behavior:
1. Set the environment variables AZURE_INFERENCE_ENDPOINT and AZURE_INFERENCE_KEY correctly.
2. Run the following code with and without providing `api_version`:
```python
import os
from azure.ai.inference import ChatCompletionsClient
from azure.core.credentials import AzureKeyCredential
from azure.ai.inference.models import SystemMessage, UserMessage

try:
client = ChatCompletionsClient(
endpoint=os.getenv("AZURE_INFERENCE_ENDPOINT"),
credential=AzureKeyCredential(os.getenv("AZURE_INFERENCE_KEY")),
#api_version="2024-12-01-preview",
)

response = client.complete(
messages=[
SystemMessage(content="You are a helpful assistant."),
UserMessage(content="What is the capital of France?"),
],
model="o3-mini",
)

print("azure-ai-inference response:", response.choices[0].message.content)

except Exception as e:
print(f"Error: {e}")

```

**Expected behavior**
I expected the API call to succeed and return a chat completion response from the o3-mini model.
Instead, it fails due to an API version mismatch.

**Screenshots**
N/A (Error is text-based and printed to console)

**Additional context**
- Other models (e.g., gpt-4o) work without issues using the same setup.
- The same model works with the AzureOpenAI library

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.