Error code 404: DeploymentNotFound in GPT-4o

Joaquín Bonifacino 40 Reputation points
2024-06-12T18:29:29.3866667+00:00

We created a new deployment and updated our model name and endpoint from an earlier version to GPT-4o, however, we are receiving a 404 error when we run our code. We have checked that the endpoint, model name, and API key are all correct. The deployment has been up and running for a day. Here is our code:

from openai import AzureOpenAI
from dotenv import load_dotenv
load_dotenv()

AZURE_OPENAI_MODEL_NAME = "gpt4o"

AZURE_OPENAI_API_KEY = os.getenv("AZURE_OPENAI_API_KEY")
AZURE_OPENAI_ENDPOINT = os.getenv("AZURE_OPENAI_ENDPOINT")

client = AzureOpenAI(
  azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT"), 
  api_key=os.getenv("AZURE_OPENAI_API_KEY"),  
  api_version="2024-02-01"
)

def openai_search(content, query):
    response = client.chat.completions.create(
        model=AZURE_OPENAI_MODEL_NAME,
        messages=[
            {"role": "system", "content": content},
            {"role": "user", "content": query}
        ]
    )
    return response

And the error we are receiving is:

openai.NotFoundError: Error code: 404 - {'error': {'code': 'DeploymentNotFound', 'message': 'The API deployment for this resource does not exist. If you created the deployment within the last 5 minutes, please wait a moment and try again.'}}

We found a previous forum issue that suggests GPT-4o may not support the chat.completion function we are using: https://learn.microsoft.com/en-us/answers/questions/1692905/azure-openai-chatgpt4o-not-working-with-api. We tried the example code but still encountered the same error. Any suggestions to help resolve this issue would be appreciated. Thank you.

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

Accepted answer
  1. AshokPeddakotla-MSFT 35,971 Reputation points Moderator
    2024-06-13T12:06:04.7033333+00:00

    Joaquín Bonifacino I'm glad that your issue is resolved and thank you for posting your solution so that others experiencing the same thing can easily reference this!

    Since the Microsoft Q&A community has a policy that the question author cannot accept their own answer, they can only accept answers by others, I'll repost your solution in case you'd like to Accept the answer.

    Error Message:

    openai.NotFoundError: Error code: 404 - {'error': {'code': 'DeploymentNotFound', 'message': 'The API deployment for this resource does not exist. If you created the deployment within the last 5 minutes, please wait a moment and try again.'}}

    Solution:

    This has been resolved, it ended up we had another service with another endpoint that was giving us the 404 error.

    If you have any other questions, please let me know. Thank you again for your time and patience throughout this issue.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Joaquín Bonifacino 40 Reputation points
    2024-06-12T18:49:10.4533333+00:00

    This has been resolved, it ended up we had another service with another endpoint that was giving us the 404, sorry for the trouble

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.