A Developer's Guide to the OpenAI Deep Research API

Mark Ponomarev

Mark Ponomarev

27 June 2025

A Developer's Guide to the OpenAI Deep Research API

In the age of information overload, the ability to conduct fast, accurate, and comprehensive research is a superpower. Developers, analysts, and strategists spend countless hours sifting through documents, verifying sources, and synthesizing findings. What if you could automate this entire workflow? OpenAI's Deep Research API is a significant step in that direction, offering a powerful tool to transform high-level questions into structured, citation-rich reports.

The Deep Research API isn't just another large language model. It's an agentic system designed to tackle complex research tasks. It can autonomously decompose a query, perform web searches, execute code to analyze data, and synthesize the results into a coherent, verifiable report. It's built for depth, nuance, and trust, providing not just answers, but also the evidence behind them.

This guide will provide a developer-focused walkthrough of the Deep Research API. We'll cover everything from making your first API call to advanced prompting techniques. We'll primarily focus on two models available through the API:

By the end of this article, you'll have a solid understanding of how to integrate this powerful research agent into your own applications.

💡
Want a great API Testing tool that generates beautiful API Documentation?

Want an integrated, All-in-One platform for your Developer Team to work together with maximum productivity?

Apidog delivers all your demands, and replaces Postman at a much more affordable price!
button

OpenAI Deep Research API Pricing, Rate Limits

Choosing the right model and understanding the costs are crucial for production applications.

Choosing Your Model

Understanding the Costs

As of late 2024, the pricing for the powerful o3-deep-research model is token-based:

The higher cost for output tokens reflects the intensive synthesis and generation work the model performs.

Key Specifications (o3-deep-research)

Make Your First OpenAI Deep Research API Call

Let's dive right in. Before you can use the API, you'll need the OpenAI Python SDK.

Setup

If you haven't already, install the latest version of the library:

pip install --upgrade openai

Next, you'll need to authenticate. Import the OpenAI client and initialize it with your API key.

from openai import OpenAI
import os

# It's best practice to use an environment variable for your API key
client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))

Making the Request

A Deep Research task can take several minutes to complete, especially for complex queries. To avoid timeouts, it's highly recommended to run requests in the background. The API makes this easy.

Let's imagine we're building a tool for a healthcare financial services firm. The task is to produce a report on the economic impact of new diabetes and obesity medications. Here’s how you would structure that request:

system_message = """
You are a professional researcher preparing a structured, data-driven report on behalf of a global health economics team. Your task is to analyze the health question the user poses.

Do:
- Focus on data-rich insights: include specific figures, trends, statistics, and measurable outcomes.
- When appropriate, summarize data in a way that could be turned into charts or tables.
- Prioritize reliable, up-to-date sources: peer-reviewed research, health organizations (e.g., WHO, CDC), etc.
- Include inline citations and return all source metadata.

Be analytical, avoid generalities, and ensure that each section supports data-backed reasoning.
"""

user_query = "Research the economic impact of semaglutide on global healthcare systems."

response = client.responses.create(
  model="o3-deep-research", # Or "o3-deep-research-2025-06-26"
  input=[
    {
      "role": "developer",
      "content": [
        {
          "type": "input_text",
          "text": system_message,
        }
      ]
    },
    {
      "role": "user",
      "content": [
        {
          "type": "input_text",
          "text": user_query,
        }
      ]
    }
  ],
  reasoning={
    "summary": "auto"
  },
  tools=[
    {
      "type": "web_search_preview"
    },
    {
      "type": "code_interpreter"
    }
  ]
)

Let's break down this call:

The true power of the Deep Research API lies in the structured, detailed response object it returns. It's more than just a block of text; it's a transparent record of the research process.

The Final Report

The main output is, of course, the final report. You can access it from the last item in the output array:

# Access the final report from the response object
print(response.output[-1].content[0].text)

This will give you the complete, synthesized text generated by the model.

Citations and Sources

One of the most critical features for any serious research is citation. The Deep Research API embeds citation metadata directly into the response. Each citation is linked to a specific part of the text, allowing for easy verification.

Here's how you can extract and display the citations:

annotations = response.output[-1].content[0].annotations
for i, citation in enumerate(annotations):
    print(f"Citation {i+1}:")
    print(f"  Title: {citation.title}")
    print(f"  URL: {citation.url}")
    print(f"  Location: chars {citation.start_index}–{citation.end_index}")

This structure is invaluable for building applications that require high degrees of trust and transparency. You can use it to create clickable footnotes, build a bibliography, or programmatically trace claims back to their original source.

Peeking Under the Hood: Intermediate Steps

The API also exposes the agent's entire thought process. The response.output contains a log of all intermediate steps taken to arrive at the final answer. This is incredibly useful for debugging, analysis, or simply understanding how the agent works.

reasoning = next(item for item in response.output if item.type == "reasoning")
for s in reasoning.summary:
    print(s.text)
search = next(item for item in response.output if item.type == "web_search_call")
print("Query:", search.action["query"])
code_step = next((item for item in response.output if item.type == "code_interpreter_call"), None)
if code_step:
    print("Code Input:", code_step.input)
    print("Code Output:", code_step.output)

Using OpenAI Deep Research with MCP Servers

Advanced Research with MCP Servers


While web search gives the Deep Research agent access to a vast repository of public information, its true power is unlocked when you connect it to your own private data.

This is where the Model Context Protocol (MCP) comes in. MCP allows you to build custom tools that extend the agent's capabilities, enabling it to query your internal knowledge bases, databases, or other proprietary services.

One of the popular MCP Server currently is Apidog MCP Server, which allows you to connect to your API Documentation within Cursor and other AI Coding tools, and greatly reduces AI hallucination by pulling from the factual API Specs.

button

Conclusion: The Future of Automated Research

The OpenAI Deep Research API is more than just an incremental improvement. It represents a fundamental shift in how we can leverage AI for knowledge work. By providing an agent that can reason, plan, execute tools, and produce verifiable results, OpenAI has created a building block for a new generation of research applications.

Whether you're building competitive intelligence dashboards, automating literature reviews, or creating sophisticated market analysis reports, the Deep Research API provides the power, transparency, and trust required for serious, real-world use cases. As the cookbook hints, the next step is likely fully-fledged "Deep Research Agents," suggesting an even more autonomous and capable future. For now, the API gives developers an incredible new tool to explore. Start building with it today.

Explore more

How to Get Free Gemini 2.5 Pro Access + 1000 Daily Requests (with Google Gemini CLI)

How to Get Free Gemini 2.5 Pro Access + 1000 Daily Requests (with Google Gemini CLI)

Google's free Gemini CLI, the open-source AI agent, rivals its competitors with free access to 1000 requests/day and Gemini 2.5 pro. Explore this complete Gemini CLI setup guide with MCP server integration.

27 June 2025

How to Use MCP Servers in LM Studio

How to Use MCP Servers in LM Studio

The world of local Large Language Models (LLMs) represents a frontier of privacy, control, and customization. For years, developers and enthusiasts have run powerful models on their own hardware, free from the constraints and costs of cloud-based services.However, this freedom often came with a significant limitation: isolation. Local models could reason, but they could not act. With the release of version 0.3.17, LM Studio shatters this barrier by introducing support for the Model Context Proto

26 June 2025

Gemini CLI: Google's Open Source Claude Code Alternative

Gemini CLI: Google's Open Source Claude Code Alternative

For decades, the command-line interface (CLI) has been the developer's sanctuary—a space of pure efficiency, control, and power. It's where code is born, systems are managed, and real work gets done. While graphical interfaces have evolved, the terminal has remained a constant, a testament to its enduring utility. Now, this venerable tool is getting its most significant upgrade in a generation. Google has introduced Gemini CLI, a powerful, open-source AI agent that brings the formidable capabili

25 June 2025

Practice API Design-first in Apidog

Discover an easier way to build and use APIs