# llms.txt

[llms.txt](https://llmstxt.org/) 是一项拟议标准，旨在使网站内容对大语言模型更易于访问。与用于网络爬虫的 `robots.txt` 类似，`llms.txt` 告知 AI 工具有哪些文档可用以及如何访问这些文档。

## 文件

WEEX API 文档提供两个 llms.txt 文件：

| 文件 | URL | 描述 |
| --- | --- | --- |
| `llms.txt` | <a href="/zh-CN/llms.txt" target="_blank" rel="noopener noreferrer">/api-doc/zh-CN/llms.txt</a> | 摘要 — 文档标题、描述和链接 |
| `llms-full.txt` | <a href="/zh-CN/llms-full.txt" target="_blank" rel="noopener noreferrer">/api-doc/zh-CN/llms-full.txt</a> | 完整内容 — 所有文档汇集在一个文件中 |

## 格式

### llms.txt（摘要）

摘要文件包含所有文档页面的结构化列表，包括标题、描述和 URL：

```text
# WEEX API 文档

> 面向大语言模型的文档索引

## 现货

- [更新日志](https://www.weex.com/api-doc/zh-CN/products/spot/changelog.md)
- [API 简介](https://www.weex.com/api-doc/zh-CN/products/spot/introduction/APIBriefIntroduction.md): 欢迎使用 WEEX API 开发者文档！
...

## 合约

- [更新日志](https://www.weex.com/api-doc/zh-CN/products/futures/changelog.md)
...
```

### llms-full.txt（完整内容）

完整文件包含每个文档页面的完整 Markdown 内容，以标题分隔。这对于将整套文档加载到大语言模型的上下文窗口中非常有用。

## 使用示例

### 输入到任意大语言模型

```bash
# 下载并用作上下文
curl -s https://www.weex.com/api-doc/zh-CN/llms.txt

# 完整文档，用于全面的上下文
curl -s https://www.weex.com/api-doc/zh-CN/llms-full.txt
```

### 与 Claude 配合使用

```text
请阅读 https://www.weex.com/api-doc/zh-CN/llms.txt，并帮助我了解
如何使用 WEEX API 下合约订单。
```

### 在 Python 脚本中使用

```python
import requests

# 获取文档索引
response = requests.get("https://www.weex.com/api-doc/zh-CN/llms.txt")
docs_index = response.text

# 将其作为上下文输入到大语言模型
messages = [
    {"role": "system", "content": f"WEEX API docs:\n{docs_index}"},
    {"role": "user", "content": "如何查询账户余额？"}
]
```

### 与 LangChain 配合使用

```python
from langchain_community.document_loaders import WebBaseLoader

loader = WebBaseLoader("https://www.weex.com/api-doc/zh-CN/llms-full.txt")
docs = loader.load()
```

## 何时使用 llms.txt 与其他选项

- **llms.txt** — 您希望快速让大语言模型了解所有可用文档，或将完整文档加载到上下文中。
- **OpenAPI Schema** — 您需要结构化 API 数据进行接口发现、代码生成或 API 工具集成。
- **Markdown 页面** — 您只需要读取单个文档页面的完整内容。
