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

# OpenAI SDK 集成

將 OpenAI SDK 連接到 TalorData MCP 伺服器，使 GPT-4o 和 o 系列模型能夠即時進行網路搜尋、抓取和結構化數據訪問。

### 託管 MCP

{% stepper %}
{% step %}

#### 獲取**您的 API 令牌**

* 前往 [SERP API-API Token](https://dashboard.talordata.com/scraping/serp-api/api-token/) 創建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": "TalorData",
      "server_url": "https://mcp.talordata.net/API_TOKEN/mcp",
      "require_approval": "never",
    },
  ],
  input="What is the weather in Paris ?",
)

print(resp.output_text)
```

{% endstep %}

{% step %}

#### 測試一下是否有效

* 問你的人工智能：“你能用 Google 搜索‘今天的天氣’嗎？”
* AI會請求許可——點擊“允許”。
* 你應該能看到效果！

{% endstep %}

{% step %}

#### 監控使用情况

* 在 TalorData [**SERP API-使用記錄**](https://dashboard.talordata.com/scraping/serp-api/history) 中查看您的 API 使用情况。

{% endstep %}
{% endstepper %}
