---
title: "给 AI 编程工具用"
description: "把 pirouter 文档交给 Cursor、Claude Code 这类编程 Agent：每页都有 Markdown 版本，另有 llms.txt 索引、全文文件和一个免鉴权的文档 MCP 服务。"
canonical: "https://pirouter.ai/zh/docs/build-with-ai"
last-updated: "2026-10-17"
lang: "zh"
source: "content/docs/zh/(start)/build-with-ai.mdx"
---

# 给 AI 编程工具用

把 pirouter 文档交给 Cursor、Claude Code 这类编程 Agent：每页都有 Markdown 版本，另有 llms.txt 索引、全文文件和一个免鉴权的文档 MCP 服务。

编程 Agent 读 Markdown 比读网页准。pirouter 文档的每一页都有 Markdown 版本，另有一份页面索引 `llms.txt` 和一个免鉴权的 MCP 服务，选一种接进你的工具即可。

## 每页的 Markdown 版本

任何一页文档的地址后面加 `.md`，返回这一页的 Markdown，例如 [`/zh/docs/quickstart.md`](https://pirouter.ai/zh/docs/quickstart.md)。文档首页是 `/zh/docs/index.md`。

请求头写 `Accept: text/markdown` 时，页面原地址也直接返回 Markdown。

每页标题下的 **复制页面** 菜单可以把这一页复制为 Markdown，或者直接在 ChatGPT、Claude 里打开并提问。

## llms.txt 与全文

| 文件                                                                    | 内容                                  |
| --------------------------------------------------------------------- | ----------------------------------- |
| [`/zh/docs/llms.txt`](https://pirouter.ai/zh/docs/llms.txt)           | 全部页面的索引：按分区列出每页的标题、Markdown 地址和一句描述 |
| [`/zh/docs/llms-full.txt`](https://pirouter.ai/zh/docs/llms-full.txt) | 全部页面的 Markdown 全文，合成一个文件            |

英文版去掉 `/zh`。Agent 只需要找某一页时给它 `llms.txt`；要让它一次读完整套文档时给 `llms-full.txt`，后者很长，会占用较多上下文。

## 文档 MCP 服务

支持 MCP 的工具可以直接连文档服务，不需要 API key：

```text
https://pirouter.ai/docs/mcp
```

传输方式是 Streamable HTTP，只读，提供两个工具：

| 工具            | 作用                                         |
| ------------- | ------------------------------------------ |
| `search_docs` | 全文搜索，`locale` 传 `zh` 搜中文页，`limit` 取 1 到 10 |
| `read_doc`    | 按路径或搜索结果里的 URL 读取一页的 Markdown              |

在 Claude Code 里添加：

```bash
claude mcp add --transport http pirouter-docs https://pirouter.ai/docs/mcp
```

其他工具在 MCP 设置里添加一个 HTTP 类型的服务器，地址同上。

## 可以粘贴的规则

把下面这段放进项目的 `AGENTS.md`（或 `CLAUDE.md`、`.cursor/rules`），Agent 写调用 pirouter 的代码时就会照文档来：

`AGENTS.md`:

```markdown
## pirouter

- Docs: https://pirouter.ai/docs/llms.txt (append `.md` to any docs URL for Markdown).
- Base URLs: OpenAI protocol https://api.pirouter.ai/v1; Anthropic and Gemini protocols https://api.pirouter.ai.
- Auth: `Authorization: Bearer $PIROUTER_API_KEY`. Never hard-code the key.
- Model IDs are `vendor/model`, e.g. `openai/gpt-6.1-sol`. List them with `GET https://api.pirouter.ai/v1/models`.
- Branch on `error.code`, not on `error.message`. Do not retry 402.
```

## 下一步

- [快速开始](https://pirouter.ai/zh/docs/quickstart.md): 创建 key，充值，调通一个模型。
- [集成](https://pirouter.ai/zh/docs/integrations.md): 把官方 SDK 和框架指向 pirouter。
