404 Resource not found when calling GPT-5-Chat via Azure AI Foundry inference endpoint

sagul jafarullah 0 Reputation points
2025-08-09T11:24:45.42+00:00

What I’ve tried:

Verified the endpoint is correct and ends with /v1.

Confirmed the key is from the Foundry inference deployment (not Azure OpenAI).

Tried both the OpenAI Python SDK and cURL.

Ensured the model name in the request is exactly gpt-5-chat.

Tested immediately after deployment and waited >10 minutes in case of propagation delay.

Attempted both Authorization: Bearer <key> and api-key: <key> headers.

Sample request (PowerShell):

powershell
Copy
$endpoint = "https://sagul-me43r8sb-swedencentral.services.ai.azure.com/v1/chat/completions"
$key      = "<FOUNDRY_INFERENCE_KEY>"

$body = @{
  model    = "gpt-5-chat"
  messages = @(
    @{ role = "system"; content = "You are helpful." },
    @{ role = "user";   content = "Say hello" }
  )
  max_tokens = 50
} | ConvertTo-Json -Depth 5

Invoke-RestMethod -Method Post -Uri $endpoint `
  -Headers @{ "api-key" = $key; "Content-Type" = "application/json" } `
  -Body $body

Error returned:

json
Copy
{"error":{"code":"404","message":"Resource not found"}}

I need guidance on:

Whether api-key authentication is supported for Foundry inference endpoints.

If there’s a configuration step required in Azure AI Foundry for the endpoint to be usable with the SDK.

  • Any known issues with gpt-5-chat in the Sweden Central region.What I’ve tried:
    • Verified the endpoint is correct and ends with /v1.
    • Confirmed the key is from the Foundry inference deployment (not Azure OpenAI).
    • Tried both the OpenAI Python SDK and cURL.
    • Ensured the model name in the request is exactly gpt-5-chat.
    • Tested immediately after deployment and waited >10 minutes in case of propagation delay.
    • Attempted both Authorization: Bearer <key> and api-key: <key> headers.
    Sample request (PowerShell):
      powershell
      Copy
      $endpoint = "https://sagul-me43r8sb-swedencentral.services.ai.azure.com/v1/chat/completions"
    

$key = "<FOUNDRY_INFERENCE_KEY>"

$body = @{ model = "gpt-5-chat" messages = @( @{ role = "system"; content = "You are helpful." }, @{ role = "user"; content = "Say hello" } ) max_tokens = 50 } | ConvertTo-Json -Depth 5

Invoke-RestMethod -Method Post -Uri $endpoint -Headers @{ "api-key" = $key; "Content-Type" = "application/json" } -Body $body

  
  **Error returned:**
  
  ```yaml
  json
  Copy
  {"error":{"code":"404","message":"Resource not found"}}

I need guidance on:

  • Whether api-key authentication is supported for Foundry inference endpoints.
  • If there’s a configuration step required in Azure AI Foundry for the endpoint to be usable with the SDK.
  • Any known issues with gpt-5-chat in the Sweden Central region.
Azure OpenAI in Foundry Models

1 answer

Sort by: Most helpful
  1. Manas R Mohanty 17,270 Reputation points Moderator
    2025-08-11T02:24:17.5+00:00

    Hi sagul jafarullah

    Here is the analysis based on your inputs.

    Region Availability

    GPT-5 is currently supported for global standard deployment for East US 2 and Sweden central Global Standard and Data zone deployment.

    https://learn.microsoft.com/en-us/azure/ai-foundry/openai/how-to/reasoning?tabs=gpt-5%2Cpython-secure%2Cpy#availability

    Endpoint format

    The endpoint used in your code is using v1/chat completion and not using api version too

      $endpoint = "https://sagul-me43r8sb-swedencentral.services.ai.azure.com/v1/chat/completions"
    

    As per documentation

    Suggested syntax for text chat completion is as below

    POST https://{resource}.services.ai.azure.com/models/chat/completions?api-version=2024-05-01-preview
    {
      "modalities": [
        "text"
      ],
      "messages": [
        {
          "role": "system",
          "content": "You are a helpful assistant"
        },
        
         "role": "user", 
         "content": "Explain Riemann's conjecture" 
        }
      "frequency_penalty": 0,
      "presence_penalty": 0,
      "temperature": 0,
      "top_p": 0,
      "seed": 21,
      "model": "my-model-name"
    }]
    
    

    Correct Usage in Azure OpenAI SDK

    
    import os
    import base64
    from openai import AzureOpenAI
    
    endpoint = os.getenv("ENDPOINT_URL", "https://<yourazureopaniname>.openai.azure.com/") deployment = os.getenv("DEPLOYMENT_NAME", "gpt-5")
    subscription_key = os.getenv("AZURE_OPENAI_API_KEY", "REPLACE_WITH_YOUR_KEY_VALUE_HERE")
    
    # Initialize Azure OpenAI client with key-based authentication
    client = AzureOpenAI(
        azure_endpoint=endpoint,
        api_key=subscription_key,
        api_version="2025-01-01-preview",
    )
    
    # IMAGE_PATH = "YOUR_IMAGE_PATH"
    # encoded_image = base64.b64encode(open(IMAGE_PATH, 'rb').read()).decode('ascii')
    
    # Prepare the chat prompt
    chat_prompt = [
        {
            "role": "developer",
            "content": [
                {
                    "type": "text",
                    "text": "You are an AI assistant that helps people find information."
                }
            ]
        },
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "How would earth look to aliens."
                }
            ]
        }
    ]
    
    # Include speech result if speech is enabled
    messages = chat_prompt
    
    # Generate the completion
    completion = client.chat.completions.create(
        model=deployment,
        messages=messages,
        max_completion_tokens=16384,
        stop=None,
        stream=False
    )
    
    print(completion.to_json())
        
    
    

    Ask

    Could you also confirm that

    You had O3 access prior or GPT 5 image access through Gated form already.

    Thank you

    Was this answer helpful?

    0 comments No comments

Your answer

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