> For the complete documentation index, see [llms.txt](https://doc.thordata.com/doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.thordata.com/doc/scraping/serp-api/integration/mcp-integration/openai-sdk-integration.md).

# OpenAI SDK Integration

Connect Thordata MCP Server to the OpenAI SDK so GPT models can perform real-time web searches, scraping, and structured data retrieval.

Integrate Thordata MCP Server with OpenAI SDK to give AI agents access to real-time SERP data and structured search results.

Connect the OpenAI SDK to the ThorData MCP server to enable GPT-4o and o-series models to perform real-time web searches, scraping, and structured data access.

#### Hosted MCP

{% stepper %}
{% step %}
**Get your API token**

* Go to [SERP API-API Token](https://dashboard.thordata.com/) to create an API token.
* Copy your API Token (format as: `sk_7qBRe***************************`）
  {% endstep %}

{% step %}
**Configure your MCP server**

```
from openai import OpenAI

client = OpenAI()

resp = client.responses.create(
  model="gpt-4o",
  tools=[
    {
      "type": "mcp",
      "server_label": "ThorData",
      "server_url": "https://mcp.thordata.net/API_TOKEN/mcp",
      "require_approval": "never",
    },
  ],
  input="What is the weather in Paris ?",
)

print(resp.output_text)
```

{% endstep %}

{% step %}
**Testing to see if it works.**

* Ask your AI: "Can you use Google to search for 'today's weather'?"
* The AI ​​will request permission—click "Allow."
* You should be able to see results!
  {% endstep %}

{% step %}
**Monitor usage**

* View your API usage in the [**ThorData SERP API usage logs**](https://dashboard.thordata.com/).
  {% endstep %}
  {% endstepper %}
