Is the new OpenAI Agents SDK for python supported in Azure OpenAI?

MattSkogmo-5557 25 Reputation points
2025-03-26T14:07:28.2533333+00:00

Open AI recently made agentic development WAY easier with the OpenAI Agents SDK for Python.

I was trying to use this in my Azure OpenAI deployment, but wasnt successful. Is there any intent to support this API?

Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
3,601 questions
{count} vote

Accepted answer
  1. Ryan Little 75 Reputation points
    2025-03-28T21:00:54.45+00:00

    Yes, you can use the new OpenAI Agents SDK with Azure OpenAI.

    I found the following blog post from Microsoft Tech Community, and have included a relevant snippet below.

    Use Azure OpenAI and APIM with the OpenAI Agents SDK

    Currently, we make use of the existing Chat Completions API rather than the newly released Responses API.

    # from: Use Azure OpenAI and APIM with the OpenAI Agents SDK
    from openai import AsyncAzureOpenAI
    from agents import set_default_openai_client
    from dotenv import load_dotenv
    import os
    
    # Load environment variables
    load_dotenv()
    
    # Create OpenAI client using Azure OpenAI
    openai_client = AsyncAzureOpenAI(
        api_key=os.getenv("AZURE_OPENAI_API_KEY"),
        api_version=os.getenv("AZURE_OPENAI_API_VERSION"),
        azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"),
        azure_deployment=os.getenv("AZURE_OPENAI_DEPLOYMENT")
    )
    
    # Set the default OpenAI client for the Agents SDK
    set_default_openai_client(openai_client)
    
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Saideep Anchuri 9,425 Reputation points Microsoft External Staff Moderator
    2025-03-26T15:14:49.3866667+00:00

    Hi MattSkogmo-5557

    You can use SDK for Azure AI foundry Agent too.

    Here is sample code -  

    agent = project_client.agents.create_agent(
        model="gpt-4o-mini",
        name="my-agent",
        instructions="You are helpful agent",
        tools=code_interpreter.definitions,
        tool_resources=code_interpreter.resources,
    )
    
    # Create a thread with messages
    thread = project_client.agents.create_thread()
    message = project_client.agents.create_message(
        thread_id=thread.id,
        role="user",
        content="Could you please create a bar chart for the operating profit using the following data and provide the file to me? Company A: $1.2 million, Company B: $2.5 million, Company C: $3.0 million, Company D: $1.8 million",
    )
    
    # Ask the agent to perform work on the thread
    run = project_client.agents.create_and_process_run(thread_id=thread.id, agent_id=agent.id)
    
    # Fetch and log all messages to see the agent's response
    messages = project_client.agents.list_messages(thread_id=thread.id)
    print(f"Messages: {messages}")
    
    

    Kindly refer below link: Azure Ai service Agent overview

    Thank You.


  2. MattSkogmo-5557 25 Reputation points
    2025-03-31T15:52:08.9633333+00:00

    Answered my own question via another, helpful route:
    Yes, you can use it! @Ryan Little you are correct. Thanks, and here is a link to a more thoroughly worked example: https://github.com/hieumoscow/azure-openai-agents?tab=readme-ov-file

    The agentic part of the example works great -- it will still complain a bit because it appears that tracing requires an openAI api key, but the rest is wonderful.

    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.