> 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/zh/pa-qu/serp-api/ji-cheng/mcp-ji-cheng/openai-sdk-ji-cheng.md).

# OpenAI SDK 集成

将 Thordata MCP Server 连接到 OpenAI SDK，使 GPT 模型能够执行实时网页搜索、抓取和结构化数据获取。

**托管 MCP**

{% stepper %}
{% step %}
**获取您的 API 令牌**

* 前往 [SERP API-API Token](https://dashboard.thordata.com/) 创建API Token
* 复制您的API Token（格式如下：`sk_7qBRe***************************`）
  {% endstep %}

{% step %}
**配置您的MCP服务器**

```
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 %}
**测试一下是否有效**

* 问你的人工智能：“你能用 Google 搜索‘今天的天气’吗？”
* AI会请求许可——点击“允许”。
* 你应该能看到效果！
  {% endstep %}

{% step %}
**监控使用情况**

* 在 ThorData [**SERP API-使用记录**](https://dashboard.thordata.com/) 中查看您的 API 使用情况。
  {% endstep %}
  {% endstepper %}
