Why is Azure OpenAI not responding to my API calls?

Mark Smith 20 Reputation points
2024-10-16T18:34:04.11+00:00

Hi all,

I'd like to get a bit of help with why Azure OpenAI is not responding to my API call. It used to respond with the same code, but it has since stopped, and doesn't even respond with an error making troubleshooting a bit of a hassle.

Here is the function in python:

def call_open_ai(transcript):

client = AzureOpenAI(

azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT"),

api_key=os.getenv("AZURE_OPENAI_API_KEY"),

api_version="2024-02-01"

)

response = client.chat.completions.create(

model="gpt-4", # model = "deployment_name".

messages=[

{"role": "user", "content": transcript}

]

)

The environment keys and endpoints are correct:

User's imageUser's image

I figured maybe its something to do with my Quota, and that Azure OpenAI is not responding due to a quota limit:

User's image

But this just looks like what I have allocated per minute not in totality.

Its extra confusing that the models will respond in their respective chats, its just the API call that doesn't function, without returning an error and just "None".User's image

Just in case it is anything to do with my subscription level, I have the most basic billing level for Azure with "standard" pricing tier for Azure.

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. Pavankumar Purilla 8,335 Reputation points Microsoft External Staff Moderator
    2024-10-17T05:41:28.79+00:00

    Hi Mark Smith,
    Greetings & Welcome to Microsoft Q&A forum! Thanks for posting your query!
    I understand that you are facing some issues with your Azure OpenAI integration. I wanted to provide some guidance to help you resolve this.
    Here are some troubleshoot steps:

    • Try Clear browser cache and cookies and also try using a different browser.
    • Sometimes, the service may experience downtime, or other issues please retry once.

    Here’s the updated code for your reference:

    
    from openai import AzureOpenAI
    
    def get_openai_response(user_prompt):
        # Initialize Azure OpenAI client using environment variables
        azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")  # Your Azure OpenAI endpoint
        api_key = os.getenv("AZURE_OPENAI_API_KEY")  # Your Azure OpenAI API key
    
        client = AzureOpenAI(
            azure_endpoint=azure_endpoint,
            api_key=api_key,
            api_version="2024-02-01",
        )
    
        # Prepare the chat prompt
        chat_prompt = [
            {
                "role": "system",
                "content": "You are an AI assistant that helps people find information."
            },
            {
                "role": "user",
                "content": user_prompt  # Use the user_prompt argument here
            }
        ]
    
        # Generate the completion
        completion = client.chat.completions.create(
            model="gpt-4",  # Replace with your actual deployment name if different
            messages=chat_prompt,
            max_tokens=800,
            temperature=0.7,
            top_p=0.95,
            frequency_penalty=0,
            presence_penalty=0,
            stop=None,
            stream=False
        )
    
        return completion.to_json()
    
    # Example usage
    response = get_openai_response("What is the capital of France?")
    print(response)
    

    Here is the screenshot of my results for your reference:codeeeeeeeeeeeeeeeeeee
    I believe this issue is not related to your quota; however, if you continue to experience difficulties, please feel free to reach out and will escalate the issue to the appropriate team to ensure it is resolved promptly.
    I hope this information helps.


    If this answers your query, do click Accept Answer and Yes for was this answer helpful.


1 additional answer

Sort by: Most helpful
  1. Mark Smith 20 Reputation points
    2024-10-18T14:57:43.6666667+00:00

    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.