> ## Documentation Index
> Fetch the complete documentation index at: https://apidoc.cometapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 將 n8n 連接到 CometAPI

> 使用本指南，透過設定 base URL、API key，以及 model 或 provider 選項，將 n8n 連接到 CometAPI。

[n8n](https://n8n.io/) 是一個工作流程自動化工具。透過設定與 OpenAI 相容的憑證將它連接到 CometAPI——所有 CometAPI 模型皆可直接使用。

## 先決條件

* 一個 [n8n](https://n8n.io/) 帳戶（雲端版或自行託管）
* 一個已啟用 API key 的 [CometAPI](https://www.cometapi.com) 帳戶

<Note>
  若為本機／自行託管的 n8n 搭配 CometAPI 社群節點，請參閱 [n8n Local Deployment](/zh-Hant/integrations/n8n-local-deployment) 指南。
</Note>

## 設定

<Steps>
  <Step title="取得你的 CometAPI API key">
    登入 [CometAPI 控制台](https://www.cometapi.com/console)。點擊 **Add API Key** 並複製你的 key 與 base URL（`https://api.cometapi.com`）。

    <Frame>
      <img src="https://mintcdn.com/cometapi/SZhlxZhCnMLn__BW/images/overview/810968_364191.png?fit=max&auto=format&n=SZhlxZhCnMLn__BW&q=85&s=aef81a83f29f8eb16655ed4060425f50" alt="CometAPI 控制台 — Add API Key" width="3824" height="1892" data-path="images/overview/810968_364191.png" />
    </Frame>

    <Frame>
      <img src="https://mintcdn.com/cometapi/HhtmQffktazbxUvS/images/overview/810968_364193.png?fit=max&auto=format&n=HhtmQffktazbxUvS&q=85&s=d893f659267150d0faf45f99eb5dffc1" alt="CometAPI API key 與 base URL" width="2434" height="1232" data-path="images/overview/810968_364193.png" />
    </Frame>
  </Step>

  <Step title="建立 OpenAI credential">
    在 n8n 中，前往你的專案 → **Credentials** → **Create Credential** → **OpenAI API**。將你的 CometAPI key 貼到 **API Key**，在 **Base URL** 欄位輸入 `https://api.cometapi.com/v1`，然後點擊 **Save**。

    <Frame>
      <img src="https://mintcdn.com/cometapi/mA1ovj6s0e3RM42l/images/integrations/810968_354031.png?fit=max&auto=format&n=mA1ovj6s0e3RM42l&q=85&s=915bfac17a897d2df0a6868a71fd1618" alt="已選取 OpenAI API 的 n8n Create Credential 對話框" width="1915" height="965" data-path="images/integrations/810968_354031.png" />
    </Frame>

    <Frame>
      <img src="https://mintcdn.com/cometapi/mA1ovj6s0e3RM42l/images/integrations/810968_354032.png?fit=max&auto=format&n=mA1ovj6s0e3RM42l&q=85&s=c94c58a1f8826554f7b703d376c3ce53" alt="已填入 CometAPI key 與 base URL 的 n8n OpenAI credential 表單" width="1886" height="924" data-path="images/integrations/810968_354032.png" />
    </Frame>

    <Frame>
      <img src="https://mintcdn.com/cometapi/mA1ovj6s0e3RM42l/images/integrations/810968_354037.png?fit=max&auto=format&n=mA1ovj6s0e3RM42l&q=85&s=e46a7e333b897ec09a791a26bb8db13f" alt="n8n credential 已成功儲存" width="1166" height="723" data-path="images/integrations/810968_354037.png" />
    </Frame>
  </Step>

  <Step title="測試連線">
    使用已儲存的 credential 建立一個包含 OpenAI 節點的工作流程並執行。成功的回應表示設定運作正常。

    <Frame>
      <img src="https://mintcdn.com/cometapi/mA1ovj6s0e3RM42l/images/integrations/810968_354039.png?fit=max&auto=format&n=mA1ovj6s0e3RM42l&q=85&s=4707697d418bff1dec20eb42dd5a2c60" alt="顯示來自 CometAPI 成功回應的 n8n 工作流程" width="1940" height="950" data-path="images/integrations/810968_354039.png" />
    </Frame>
  </Step>
</Steps>

<script type="application/ld+json">
  {`
    {
    "@context": "https://schema.org",
    "@graph": [
      {
        "@type": "HowTo",
        "@id": "https://apidoc.cometapi.com/integrations/n8n#howto",
        "name": "將 n8n 連接到 CometAPI",
        "description": "使用本指南，透過設定 base URL、API key，以及 model 或 provider 選項，將 n8n 連接到 CometAPI。",
        "step": [
          {
            "@type": "HowToStep",
            "@id": "https://apidoc.cometapi.com/integrations/n8n#step-1",
            "position": 1,
            "name": "取得你的 CometAPI API key",
            "text": "建立或開啟你的 CometAPI 帳戶，然後從控制台複製一個啟用中的 API key。"
          },
          {
            "@type": "HowToStep",
            "@id": "https://apidoc.cometapi.com/integrations/n8n#step-2",
            "position": 2,
            "name": "建立 OpenAI credential",
            "text": "在「將 n8n 連接到 CometAPI」指南中完成「建立 OpenAI credential」步驟。"
          },
          {
            "@type": "HowToStep",
            "@id": "https://apidoc.cometapi.com/integrations/n8n#step-3",
            "position": 3,
            "name": "測試連線",
            "text": "從 CometAPI Models 頁面選擇目前的 model ID，然後從整合發送測試請求。"
          }
        ]
      },
      {
        "@type": "BreadcrumbList",
        "itemListElement": [
          {
            "@type": "ListItem",
            "position": 1,
            "name": "CometAPI 文件",
            "item": "https://apidoc.cometapi.com/"
          },
          {
            "@type": "ListItem",
            "position": 2,
            "name": "整合",
            "item": "https://apidoc.cometapi.com/integrations"
          },
          {
            "@type": "ListItem",
            "position": 3,
            "name": "將 n8n 連接到 CometAPI",
            "item": "https://apidoc.cometapi.com/integrations/n8n"
          }
        ]
      }
    ]
    }
    `}
</script>
