> ## 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.

# 將 CometAPI 文件與 LLM 搭配使用

> 將 CometAPI 的 llms.txt 與 llms-full.txt 用於程式編碼助理、檢索系統與模型 Prompt。

當你需要 CometAPI 文件頁面的精簡索引時，請使用 `llms.txt`。當你的工具可以擷取完整文件文字，用於檢索、問答或程式編碼協助時，請使用 `llms-full.txt`。

## 取得精簡索引

以下請求會下載 CometAPI 的 `llms.txt` 索引：

```bash theme={null}
curl https://apidoc.cometapi.com/llms.txt
```

回應會以文件標題與連結頁面清單開頭：

```text theme={null}
# CometAPI Documentation

> CometAPI developer documentation for unified API access...

## Docs

- [Create a new API key](https://apidoc.cometapi.com/api/api-keys/create-api-key.md)
```

## 取得完整文字

以下請求會下載完整文字匯出：

```bash theme={null}
curl https://apidoc.cometapi.com/llms-full.txt
```

回應包含依來源 URL 分組的頁面內容：

```text theme={null}
# Create a new API key
Source: https://apidoc.cometapi.com/api/api-keys/create-api-key

Create a new CometAPI API key for the authenticated account.
```

## 將文件加入檢索工作

以下 Python 範例會下載完整文字，並將其寫入本機檔案以供建立索引：

```python theme={null}
from pathlib import Path

import requests

url = "https://apidoc.cometapi.com/llms-full.txt"
response = requests.get(url, timeout=60)
response.raise_for_status()

Path("cometapi-docs.txt").write_text(response.text, encoding="utf-8")
print(len(response.text))
```

結果會是已儲存的字元數。這只是範例輸出；每當文件內容變更時，你的數值都會不同：

```text theme={null}
449946
```

## 常見錯誤

| 錯誤         | 修正方式                                     |
| ---------- | ---------------------------------------- |
| 工具上下文過小    | 先使用 `llms.txt`，再僅擷取相關的連結頁面。              |
| 完整文字過大     | 在建立索引前，先依標題或來源 URL 將 `llms-full.txt` 分塊。 |
| 本機快取損毀     | 在你的文件同步工作期間重新整理該檔案。                      |
| AI 結果中缺少頁面 | 確認該頁面有出現在導覽中，且也存在於 `llms.txt`。           |

## 相關連結

* [CometAPI 文件首頁](/)
* [模型頁面](/zh-Hant/overview/models)
* [模型目錄](https://www.cometapi.com/models/)
* [定價](https://www.cometapi.com/pricing/)
* [CometAPI 快速開始](/zh-Hant/overview/quick-start)

<script type="application/ld+json">
  {`
    {
    "@context": "https://schema.org",
    "@graph": [
      {
        "@type": "TechArticle",
        "@id": "https://apidoc.cometapi.com/guides/how-to-use-cometapi-docs-with-llms",
        "headline": "如何將 CometAPI 文件與 LLM 搭配使用？",
        "description": "將 CometAPI 的 llms.txt 與 llms-full.txt 用於程式編碼助理、檢索系統與模型 Prompt。",
        "url": "https://apidoc.cometapi.com/guides/how-to-use-cometapi-docs-with-llms",
        "author": {
          "@type": "Organization",
          "name": "CometAPI"
        },
        "publisher": {
          "@type": "Organization",
          "name": "CometAPI",
          "url": "https://www.cometapi.com"
        }
      },
      {
        "@type": "BreadcrumbList",
        "itemListElement": [
          {
            "@type": "ListItem",
            "position": 1,
            "name": "CometAPI 文件",
            "item": "https://apidoc.cometapi.com/"
          },
          {
            "@type": "ListItem",
            "position": 2,
            "name": "指南",
            "item": "https://apidoc.cometapi.com/guides/use-cometapi-with-openai-sdk"
          },
          {
            "@type": "ListItem",
            "position": 3,
            "name": "如何將 CometAPI 文件與 LLM 搭配使用？",
            "item": "https://apidoc.cometapi.com/guides/how-to-use-cometapi-docs-with-llms"
          }
        ]
      }
    ]
    }
    `}
</script>
