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

# 快速入门指南

> 几分钟内开始使用 LLMGenerator API。通过一次 API 调用生成您的第一个 llms.txt 文件。

本指南将引导您完成使用 LLMGenerator API 的基本步骤。完成后，您将能够生成第一个 `llms.txt` 文件。

## 1. 创建账户并获取 API 密钥

在使用 API 之前，您需要创建一个 LLMGenerator 账户并获取 API 密钥。

1. **注册**: 在 LLMGenerator 控制台[创建账户](https://llmgenerator.com/sign-up)。
2. **进入 API 设置**: 登录后，在账户设置中找到"API 密钥"部分。
3. **创建密钥**: 生成新的 API 密钥。请务必复制并安全保存，之后将无法再次查看。

您的 API 密钥格式如下：`llmgen_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`

## 2. 发送第一个 API 请求

现在可以使用 API 密钥向 LLMGenerator API 发送请求了。创建 `llms.txt` 文件的主要端点是 `/api/v1/generate`。

您需要发送 `POST` 请求，并在 `Authorization` 请求头中以 Bearer token 形式传入 API 密钥。

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.llmgenerator.com/api/v1/generate \
    -H "Authorization: Bearer 您的API密钥" \
    -H "Content-Type: application/json" \
    -d '{
      "url": "https://www.example.com",
      "options": {
        "maxUrls": 10,
        "showFullText": true,
        "generationMethod": "simple"
      }
    }'
  ```

  ```javascript Node.js theme={null}
  const apiKey = '您的API密钥';
  const url = 'https://api.llmgenerator.com/api/v1/generate';

  const response = await fetch(url, {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${apiKey}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      url: 'https://www.example.com',
      options: {
        maxUrls: 10,
        showFullText: true,
        generationMethod: 'simple' // 或 'enhanced'（消耗2倍积分）
      }
    })
  });

  const data = await response.json();
  console.log(data);
  ```

  ```python Python theme={null}
  import requests

  api_key = "您的API密钥"
  api_url = "https://api.llmgenerator.com/api/v1/generate"

  headers = {
      "Authorization": f"Bearer {api_key}",
      "Content-Type": "application/json"
  }

  payload = {
      "url": "https://www.example.com",
      "options": {
          "maxUrls": 10,
          "showFullText": True,
          "generationMethod": "simple"  # 或 "enhanced"（消耗2倍积分）
      }
  }

  response = requests.post(api_url, headers=headers, json=payload)
  print(response.json())
  ```
</CodeGroup>

<Info>
  请将 `您的API密钥` 替换为第一步中获取的实际 API 密钥。
</Info>

## 3. 检查响应

如果请求成功，您将收到包含网站详情和文件 URL 的 JSON 响应：

```json theme={null}
{
  "success": true,
  "message": "llms.txt 文件生成成功",
  "site": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "url": "https://example.com",
    "status": "completed"
  },
  "fileUrl": "https://api.llmgenerator.com/api/v1/file/550e8400-e29b-41d4-a716-446655440000",
  "fullTextUrl": "https://api.llmgenerator.com/api/v1/file/550e8400-e29b-41d4-a716-446655440000?full=true",
  "creditsUsed": 10,
  "creditsRemaining": 490
}
```

## 4. 访问您的文件

生成的文件可以通过以下几种方式访问：

```bash theme={null}
# 在浏览器中查看
curl https://api.llmgenerator.com/api/v1/file/您的网站ID

# 下载为文件
curl https://api.llmgenerator.com/api/v1/file/您的网站ID/download -o llms.txt

# 获取完整文本版本
curl "https://api.llmgenerator.com/api/v1/file/您的网站ID?full=true"
```

## 后续步骤

您已成功生成了第一个 `llms.txt` 文件！以下是您接下来可以做的事情：

* 浏览完整的 [API 参考文档](/zh-cn/api-reference/introduction)，了解所有可用端点和选项。
* 了解如何在生成前使用 [URL 发现](/zh-cn/api-reference/discovery/start)查找 URL。
* 查看您的[积分余额](/zh-cn/api-reference/credits/balance)和[交易历史](/zh-cn/api-reference/credits/history)。
* 使用 [MCP 服务器](/zh-cn/integrations/mcp)与 Claude、Cursor 等 AI 智能体集成。
* 在 [LLMGenerator 控制台](https://app.llmgenerator.com)管理网站并查看分析数据。
