Azure OPENAI ChatGPT4O not working with API

Bandana Surelia 20 Reputation points

I use python code to call ChatGPT deployed model via API and get proper response for GPT-turbo and GPT-4. But when I used same code for Chat GPT4O, it gives error openai.NotFoundError: Error code: 404 - {'error': {'code': '404', 'message': 'Resource not found'}}

Sample code is as below, please suggest how can I get it working with gpt-4o?

import os
from openai import AzureOpenAI
client = AzureOpenAI(
    azure_endpoint = ""
deployment_name='gpt-4o' #This will correspond to the custom name you chose for your deployment when you deployed a model.  

# client = AzureOpenAI(
#     api_key="XXXXXXXXXXXXXXXXXX",  
#     api_version="XXXX-02-01",
#     azure_endpoint = ""
#     )
# deployment_name='gpt-35-turbo' #This will correspond to the custom name you chose for your deployment when you deployed a model.. 
# Send a completion call to generate an answer
print('Sending a test completion job')
start_phrase = 'Write a tagline for an ice cream shop. '
response = client.completions.create(model=deployment_name, prompt=start_phrase, max_tokens=10)

Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
2,482 questions
0 comments No comments
{count} votes

Accepted answer
  1. Aki Nishikawa 1,135 Reputation points Microsoft Employee

    Hello @Bandana Surelia ,

    I suppose api_version you specified in AzureOpenAI is a little bit different (line 6). You read the word 2024-05-13 in the document below but it is a model version, not API version.

    When using GPT-4o on your AOAI, could I ask you to specify one of the API versions described in REST API reference? The latest one is 2024-05-01-preview.

    2 people found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Bandana Surelia 20 Reputation points

    Hi Aki Nishikawa,

    Thank you for your response. I changed the API Version and now I get below error:

    Error code: 400 - {'error': {'code': 'OperationNotSupported', 'message': 'The completion operation does not work with the specified model, gpt-4o. Please choose different model and try again. You can learn more about which models can be used with each operation here:'}}

    Is it like we cannot use gpt-4o in chat completion? By when this feature would be available?