Share via

not able to connect openai endpoint - https://oai-cs-gpt-bsox-zxcv.openai.azure.com

Algotar, Kalpana A 1 Reputation point
2025-09-16T19:29:28.9066667+00:00

Error: Error code: 404 - {'error': {'code': '404', 'message': 'Resource not found'}}

Azure OpenAI in Foundry Models
0 comments No comments

1 answer

Sort by: Most helpful
  1. Aryan Parashar 3,695 Reputation points Microsoft External Staff Moderator
    2025-09-17T05:52:48.5933333+00:00

    Hi Kalpana,
    Please check in Azure AI Foundry whether the deployment exists with the correct model_name and deployment_name, as you need to use both when accessing them in your code:
    Select Models + endpoints in Azure AI Foundry, then copy the deployment_name (highlighted in brown) and the model_name as shown below:
    User's image

    Now use the below code to access the model:
    If using Key Based Authentication:

    import os
    from openai import AzureOpenAI
    
    endpoint = "https://oai-cs-gpt-bsox-zxcv.openai.azure.com/"
    model_name = "<model-name>"
    deployment = "<deployment-name>"
    
    subscription_key = "<your-api-key>"
    api_version = "2024-12-01-preview"
    
    client = AzureOpenAI(
        api_version=api_version,
        azure_endpoint=endpoint,
        api_key=subscription_key,
    )
    
    response = client.chat.completions.create(
        messages=[
            {
                "role": "system",
                "content": "You are a helpful assistant.",
            },
            {
                "role": "user",
                "content": "I am going to Paris, what should I see?",
            }
        ],
        max_tokens=4096,
        temperature=1.0,
        top_p=1.0,
        model=deployment
    )
    
    print(response.choices[0].message.content)
    

    If using EntraID identity:

    import os
    from openai import AzureOpenAI
    from azure.identity import DefaultAzureCredential, get_bearer_token_provider
    
    endpoint = "https://oai-cs-gpt-bsox-zxcv.openai.azure.com/"
    model_name = "<model-name>"
    deployment = "<deployment-name>"
    token_provider = get_bearer_token_provider(DefaultAzureCredential(), "https://cognitiveservices.azure.com/.default")
    api_version = "2024-12-01-preview"
    
    client = AzureOpenAI(
        api_version=api_version,
        azure_endpoint=endpoint,
        azure_ad_token_provider=token_provider,
    )
    
    response = client.chat.completions.create(
        messages=[
            {
                "role": "system",
                "content": "You are a helpful assistant.",
            },
            {
                "role": "user",
                "content": "I am going to Paris, what should I see?",
            }
        ],
        max_tokens=4096,
        temperature=1.0,
        top_p=1.0,
        model=deployment
    )
    
    print(response.choices[0].message.content)
    

    Here is the supported documentation:

    https://learn.microsoft.com/en-us/azure/ai-foundry/quickstarts/get-started-code?tabs=python

    Feel free to accept it as an answer.
    Thankyou for reaching out to to the Microsoft QNA Portal.

    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.