How to Use OpenAI’s Responses API & Agent SDK?

Anu Madan Last Updated : 12 Mar, 2025
9 min read

OpenAI has been a leading solutions provider in the GenAI space. From the legendary ChatGPT to Sora, it is a go-to platform for all the working professionals out there. With Qwen and Claude gaining popularity among developers, OpenAI is back again with its latest updates, empowering developers to create more reliable and capable AI agents. The major highlights from the list include the Responses API and Agents SDK. In this blog, we will explore the Responses API and Agents SDK, understand how to access them, and learn how to use them to build real-world applications!

What is the Responses API?

The Responses API is OpenAI’s newest API designed for simplifying the process of building AI-based applications. It combines the simplicity of the Chat Completions API with the powerful tool-use capabilities of the Assistants API. This means developers can now create agents that leverage multiple tools and handle complex, multi-step tasks more efficiently. This API reduced the reliance on complex prompt engineering and external integrations.  

Key Features of the Responses API

  • Built-in tools like web search, file search, and computer use, allowing agents to interact with real-world data.
  • Unified design that simplifies polymorphism and improves usability.
  • Better observability, helping developers track agent behavior and optimize workflows.
  • No additional costs, as it is charged based on token usage at OpenAI’s standard pricing.

With these tools, Responses API is a game changer towards building AI agents. Infact, going forward, Responses API will support all of OpenAI’s new and upcoming models. Let’s see how we can use it to build applications.

How to use Responses API?

To try Responses API:

  1. Install openai (if not already installed) and use OpenAI.
  2. Ensure you have the latest OpenAI library(pip install openai – -upgrade).
  3. Import OpenAI and Set Up the Client.

Once set up, you can request the Responses API. While basic API calls are common, its built-in capabilities make it powerful. Let’s explore three key features:

  • File Search: Retrieve insights from documents.
  • Web Search: Get real-time, cited information.
  • Computer Use: Automate system interactions.

Now, let’s see them in action!

It enables models to retrieve information in a knowledge base of previously uploaded files through semantic and keyword search. Currently it doesn’t support csv files, you can check the list of supported file types here.

Note: Before using the file search, make sure to store your files in a vector database

Task: Names of people with domain as Data Science. (I used the following File.)

Code:

response = client.responses.create(

    model="gpt-4o-mini",

    input="Names of people with domain as Data Science",

    tools=[{

        "type": "file_search",

        "vector_store_ids": [vector_store_id],

        "filters": {

            "type": "eq",

            "key": "Domain",

            "value": "Data Science"

        }

    }]

)

print(response.output_text)

Output:

The person with the domain of Data Science is Alice Johnson [0].
[0] names_and_domains.pdf

This feature allows models to search the web for the latest information before generating a response, ensuring that the data remains up to date. The model can choose to search the web or not based on the content of the input prompt.

Task : What are the best cafes in Vijay nagar?

Code:

response = client.responses.create(

    model="gpt-4o",

    tools=[{

        "type": "web_search_preview",

        "user_location": {

            "type": "approximate",

            "country": "IN",

            "city": "Indore",

            "region": "Madhya Pradesh",

        }

    }],

    input="What are the best cafe in Vijay nagar?",

)

print(response.output_text)

Output:

3. Computer Use

It is a practical application of Computer-using Agent(CUA) Model, which combines the vision capabilities of GPT-4o with advanced reasoning to simulate controlling computer interfaces and perform tasks.

Task: Check the latest blog on Analytics Vidhya website.

Code:

response = client.responses.create(

    model="computer-use-preview",

    tools=[{

        "type": "computer_use_preview",

        "display_width": 1024,

        "display_height": 768,

        "environment": "browser" # other possible values: "mac", "windows", "ubuntu"

    }],

    input=[

        {

            "role": "user",

            "content": "Check the latest blog on Analytics Vidhya website."

        }

    ],

    truncation="auto"

)

print(response.output)

Output:

ResponseComputerToolCall(id='cu_67d147af346c8192b78719dd0e22856964fbb87c6a42e96', 
action=ActionScreenshot(type='screenshot'),
call_id='call_a0w16G1BNEk09aYIV25vdkxY', pending_safety_checks=[],
status='completed', type='computer_call')

How is the Responses API Different from the Completions API?

Now that we have seen how the Responses API works, let’s see how different it is from the pre-existing Completions API.

Responses API vs Completions API: Execution

API  Responses API  Completions API
Code
from openai import OpenAI
client = OpenAI()
response = client.responses.create(
    model="gpt-4o",
    inputs=[
        {
            "role": "user",
            "content": "Write a one-sentence bedtime story about a unicorn."
        }
    ]
)
print(response.output_text)
from openai import OpenAI
client = OpenAI()
completion = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {
            "role": "user",
            "content": "Write a one-sentence bedtime story about a unicorn."
        }
    ]
)
print(completion.choices[0].message.content)
Output

Responses API vs Completions API: Features

Here is a simplified breakdown of the various features of Chat Complerions APi and Responses API:

Capabilities Responses API Chat Completions API
Text generation
Audio Coming soon
Vision
Web search
File search
Computer use
Code interpreter Coming soon
Response Handling Returns a single structured output Returns choices array
Conversation State previous_response_id for continuity Must be manually managed
Storage Behavior Stored by default (store: false to disable) Stored by default

Roadmap: What Will Continue, What Will Deprecate?

With Responses API going live, the burning question now is, would it affect the existing Chat Completions and Assistant API? Yes it would. Let’s look at how:

  • Chat Completions API: OpenAI will continue updating it with new models, but only when the capabilities don’t require built-in tools.
  • Web Search & File Search Tools: These will become more refined and powerful in the Responses API.
  • Assistants API: The Responses API incorporates its best features while improving performance. OpenAI has announced that full feature parity is coming soon, and the Assistants API will be deprecated by mid-2026.

Introducing the Agents SDK

Building AI agents is not just about having a powerful API—it requires efficient orchestration. This is where OpenAI’s Agents SDK comes into play. The Agents SDK is an open-source toolkit that simplifies agent workflows. This agent building framework integrates seamlessly with the Responses API and Chat Completions API. Additionally, it is also compatible with models from various providers, provided they offer an API endpoint styled like Chat Completions.

Some of the key features of Agents SDK are:

  • It allows developers to configure AI agents with built-in tools.
  • It enables multi-agent orchestration, allowing seamless coordination of different agents as needed.
  • It allows us to track the conversation & the flow of information between our agents.
  • It allows an easier way to apply guardrails for safety and compliance.
  • It ensures that developers can monitor and optimize agent performance with built-in observability tools.

Agent SDK isn’t a “new addition” to OpenAI’s jewels. It is an improved version of “Swarm”, the experimental SDK that OpenAI had released last year. While “Swarm” was just released for educational purposes, it became popular among developers and was adopted by several enterprises too. To cater to more enterprises and help them build production-grade agents seamlessly, Agents SDK has been released. Now that we know what Agents SDK has to offer, let’s see how we can use this framework to build our agentic system.

Also Read: Top 10 Generative AI Coding Extensions in VS Code

Build a Multi-agentic System using Agent SDK

We will build a multi-agent system that helps users with car recommendations and resale price estimation by leveraging LLM-powered agents and web search tools to provide accurate and up-to-date insights.

Step 1: Building a Simple AI Agent

We begin by creating a Car Advisor Agent that helps users choose a suitable car type based on their needs.

Code:

car_advisor = Agent(

    name="Car advisor",

    instructions= "You are an expert in advising suitable car type like sedan, hatchback etc to people based on their requirements.",

    model="gpt-4o",

    )

prompt = "I am looking for a car that I enjoy driving and comforatbly take 4 people. I plane to travel to hills. What type of car should I buy?"

async def main():

    result = await Runner.run(car_advisor, prompt)

    print(result.final_output)

# Run the function in Jupyter

await main()

Output:

Building a Simple AI Agent

Step 2: Build the Multi-Agent System

With the basic agent in place, we now create a multi-agent system incorporating different AI agents specialized in their respective domains. Here’s how it works:

Agents in the Multi-Agent System

  1. Car Sell Estimate Agent: It provides a resale price estimate based on car details.
  2. Car Model Advisor Agent: It suggests suitable car models based on budget and location.
  3. Triage Agent: It directs the query to the appropriate agent.

We will provide two different prompts to the agents and observe their outputs.

Code:

car_sell_estimate = Agent(

    name="Car sell estimate",

    instructions= "You are an expert in suggesting a suitable price of reselling a car based on its make, model, year of purchase, and condition.",

    handoff_description= "Car reselling price estimate expert",

    model="gpt-4o",

    tools=[WebSearchTool()]

    )

car_model_advisor = Agent(

    name="Car model advisor",

    instructions= "You are an expert in advising suitable car model to people based on their budget and location.",

    handoff_description= "Car model recommendation expert",

    model="gpt-4o",

    tools=[WebSearchTool()]

    )

triage_agent = Agent(

    name = "Triage Agent",

    instructions="You determine the appropriate agent for the task.",

    model = "gpt-4o",

    handoffs=[car_sell_estimate, car_model_advisor]

)

Prompt 1: 

prompt = "I want to sell my Ecosport car in New Delhi. It is 3 years old and in good condition. 50000Km. What price should I expect?"

async def main():

    result = await Runner.run(triage_agent, prompt)

    print(result.final_output)

# Run the function in Jupyter

await main()

Output 1:

SDK Output 1

Prompt 2:

prompt = "I want to buy a high acceleration car, comfortable for 4 people for 20 lakhs in New Delhi. Which car should I buy?"

async def main():

    result = await Runner.run(triage_agent, prompt)

    print(result.final_output)

# Run the function in Jupyter

await main()

Output 2:

We got the car options as per our requirements! The implementation was simple and quick. You can use this agentic framework to build agents for travel support, financial planning, medical assistance, personalized shopping, automated research, and much more.

Agent’s SDK: A New Agentic Framework in Town?

OpenAI’s Agents SDK represents its strategic push toward providing a dedicated framework for AI agent development. The framework includes crew-like features through its triage agent, mimicking Crew AI’s features. Similarly, its handoff mechanisms closely resemble those of AutoGen, allowing efficient delegation of tasks among multiple agents.

Furthermore, LangChain’s strength in modular agent orchestration is mirrored in the way the Agents SDK provides structured workflows, ensuring smooth execution and adaptability. While Agents SDK offers nothing more than what the existing frameworks already do, it soon will give them a tough competition. 

Also Read: Claude 3.7 Sonnet: The Best Coding Model Yet?

Why Do Developers Need Responses API & Agents SDK?

Responses API and Agents SDK provide developers with the tools & platform to build AI-driven applications. By reducing the reliance on manual prompt engineering and extensive custom logic, these tools allow developers to focus on creating intelligent workflows with minimal friction.

  • Easy Integration: Developers no longer need to juggle multiple APIs for different tools; the Responses API consolidates web search, file search, and computer use into a single interface.
  • Better Observability: With built-in monitoring and debugging tools, developers can optimize agent performance more easily.
  • Scalability: The Agents SDK provides a structured approach to handling multi-agent workflows, enabling more robust automation.
  • Improved Development Cycles: By eliminating the need for extensive prompt iteration and external tool integration, developers can prototype and deploy agent-based applications at a much faster pace.

Conclusion

The introduction of OpenAI’s Responses API and Agents SDK is a game-changer for AI-driven automation. By leveraging these tools, we successfully built a multi-agent system very quickly with just a few lines of code. This implementation can be further expanded to include additional tools, integrations, and agent capabilities, paving the way for more intelligent and autonomous AI applications in various industries.

These tools are surely going to help developers and enterprises reduce development complexity, and create smarter, more scalable automation solutions. Whether it’s for customer support, research, business automation, or industry-specific AI applications, the Responses API and Agents SDK offer a powerful framework to build next-generation AI-powered systems with ease.

Frequently Asked Questions

Q1. What is OpenAI’s Responses API?

A. The Responses API is OpenAI’s latest AI framework that simplifies agent development by integrating built-in tools like web search, file search, and computer use.

Q2. How is the Responses API different from the Completions API?

A. Unlike the Completions API, the Responses API supports multi-tool integration, structured outputs, and built-in conversation state management.

Q3. What is OpenAI’s Agents SDK?

A. The Agents SDK is an open-source framework that enables developers to build and orchestrate multi-agent systems with AI-powered automation.

Q4. How does the Agents SDK improve AI development?

A. It allows seamless agent coordination, enhanced observability, built-in guardrails, and improved performance tracking.

Q5. Can the Responses API and Agents SDK be used together?

A. Yes! The Agents SDK integrates with the Responses API to create powerful AI-driven applications.

Q6. Is OpenAI’s Agents SDK compatible with other AI models?

A. Yes, it can work with third-party models that support Chat Completions API-style integrations.

Q7. What industries can benefit from multi-agent AI systems?

A. Industries like automotive, finance, healthcare, customer support, and research can use AI-driven agents to optimize operations and decision-making.

Anu Madan has 5+ years of experience in content creation and management. Having worked as a content creator, reviewer, and manager, she has created several courses and blogs. Currently, she working on creating and strategizing the content curation and design around Generative AI and other upcoming technology.

Login to continue reading and enjoy expert-curated content.

Responses From Readers

We use cookies essential for this site to function well. Please click to help us improve its usefulness with additional cookies. Learn about our use of cookies in our Privacy Policy & Cookies Policy.

Show details