I have created an Azure OpenAI Resource in Azure Portal. However, the endpoint gives a 404 Resource not Found error.
I have having trouble using this resource with Prompt Flow, and I believe it it due to this error. How can I resolve the issue?
Hi, thanks for responding!. Have created resource and deployment model also. Tried multiple steps, however, looks like there is an issue with my API endpoint URL itself, as I keep getting 404 resource not found error.
I copied auto generated code from “Early Access playground”, still the generated code also gives 404 resource error when trying to access the endpoint URL. Because of this, I’m never able to make API calls to the GPT4-o model instance.
I have Azure Student Subscription, so cannot access gpt-4, and tried with gpt4-o. The loaddotenv() function loads and print my environmental variables when I test, so I guess the real problem happens when I’m trying to call the gpt 4-o instance and the endpoint doesn’t work. Not sure where I’m going wrong:
Is openai api type “OpenAI” correct, or should I use “Azure”?
Is AZURE_OPENAI_DEPLOYMENT=“gpt-4o” correct, or should I be using my deployment name and not the base model name?
What is the correct way to verify if my endpoint URL is working fine?
How to verify if I’m using the correct API version?
Any help is appreciated!
System didn’t let me post links, so I enclosed https within brackets.
My environment variables are below:
AZURE_OPENAI_API_ENDPOINT=“(https://)MYRESOURCENAMEDOTopenaiDOTazureDOTcom”
AZURE_OPENAI_API_KEY=“xxxxxxxxxxxx”
AZURE_OPENAI_DEPLOYMENT=“gpt-4o”
load_dotenv()
openai_api_type = “OpenAI”
gpt_4o_endpoint = os.getenv(“AZURE_OPENAI_API_ENDPOINT”)
gpt_4o_api_key = os.getenv(“AZURE_OPENAI_API_KEY”)
gpt_4o_deployment_name=os.getenv(“AZURE_OPENAI_DEPLOYMENT”)
Below code to call GPT4-O INSTANCE:
gpt_4o = AzureChatOpenAI(
openai_api_base=gpt_4o_endpoint,
openai_api_version="2024-05-13",
deployment_name=gpt_4o_deployment_name,
openai_api_key=gpt_4o_api_key,
openai_api_type = openai_api_type,
You can give it a try with the following basic script for an API request:
from openai import AzureOpenAI
client = AzureOpenAI(
azure_endpoint = "https://resourcename.openai.azure.com/",
api_key=("Azure OpenAI key"),
api_version="2024-05-13"
message_text = [{"role":"system","content":"You are a helpful Assistant."},{"role":"user","content":"This is a test"}]
completion = client.chat.completions.create(
model="deployment_name",
messages = message_text,
temperature=0.1,
max_tokens=100
print(completion.choices[0].message.content)
On my side, I was not able to find the “correct” credentials but I found how to get the correct credentials.
You go to the Azure OpenAI Studio, then go to “Conversation” tab, then “Show Code”, and select “curl” langage.
Then, in the initial URL you will find the correct apiKey, url, and more important, the correct apiVersion.
Be very careful, because at the end of the apiVersion, there is a “-preview”, do not forget it in your JS/python code 
on my side, I had a wrong apiVersion and so, I always had this 404 error