Azure OPENAI ChatGPT4O not working with API

Bandana Surelia 25 Reputation points
2024-06-07T11:09:50.85+00:00

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(
    api_key="xxxxxxxxxxxxxxx",  
    api_version="2024-05-13",
    azure_endpoint = "https://xxxxxxx.openai.azure.com/"
    )
    
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 = "https://xxxxxxxxxxxxx.openai.azure.com/"
#     )
    
# 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)
print(start_phrase+response.choices[0].text)

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

Accepted answer
  1. Aki Nishikawa 1,560 Reputation points Microsoft Employee
    2024-06-08T01:20:06.9933333+00:00

    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.

    https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models#how-do-i-access-the-gpt-4o-model

    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.

    https://learn.microsoft.com/en-us/azure/ai-services/openai/reference

    2 people found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Bandana Surelia 25 Reputation points
    2024-06-10T11:12:48.4033333+00:00

    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: https://go.microsoft.com/fwlink/?linkid=2197993.'}}

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

    Thanks

    Bandana

    1 person found this answer helpful.