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?

Foundry Tools
Foundry Tools

Formerly known as Azure AI Services or Azure Cognitive Services is a unified collection of prebuilt AI capabilities within the Microsoft Foundry platform


Answer accepted by question author
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)

Was this answer helpful?

0 comments No comments

2 additional answers

Sort by: Most helpful
  1. 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.

    Was this answer helpful?

    0 comments No comments

  2. Saideep Anchuri 9,545 Reputation points 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.

    Was this answer helpful?


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.