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

# 生成 llms.txt

> 为指定 URL 生成 llms.txt 文件。

## POST /generate

发起 `llms.txt` 生成任务。根据用户套餐支持 `simple` 与 `enhanced` 两种生成方式。

<Note>
  增强生成使用 AI 优化标题与描述，积分消耗为简明生成的 2 倍。
</Note>

### 请求体

<ParamField body="url" type="string" required>
  目标网站 URL，须为合法的 http/https 地址。
</ParamField>

<ParamField body="options" type="object">
  生成选项对象。

  <Expandable title="options 字段">
    <ParamField body="maxUrls" type="number" default="50">
      最多包含的 URL 数量，范围 1–1000。
    </ParamField>

    <ParamField body="showFullText" type="boolean" default="false">
      是否在输出中包含每页全文。
    </ParamField>

    <ParamField body="includeModificationDate" type="boolean" default="false">
      是否为 URL 包含最近修改日期。
    </ParamField>

    <ParamField body="generationMethod" type="string" default="enhanced">
      取值为 `simple` 或 `enhanced`。简明模式使用页面元数据；增强模式使用 AI 优化标题与描述。
    </ParamField>

    <ParamField body="cacheAge" type="number" default="3600000">
      缓存时长（毫秒），默认 1 小时以加快抓取。
    </ParamField>
  </Expandable>
</ParamField>

### 响应

<ResponseField name="jobId" type="string">
  生成任务唯一标识。
</ResponseField>

<ResponseField name="status" type="string">
  任务状态：`queued`、`processing`、`completed` 或 `failed`。
</ResponseField>

<ResponseField name="progress" type="number">
  进度百分比（0–100）。
</ResponseField>

<ResponseField name="message" type="string">
  可读的状态说明。
</ResponseField>

<ResponseField name="fileUrl" type="string">
  生成的 `llms.txt` 访问地址。
</ResponseField>

<ResponseField name="fullTextUrl" type="string">
  全文版 llms.txt 地址（当启用 showFullText 时）。
</ResponseField>

<ResponseField name="siteId" type="string">
  本次生成创建或更新的站点 ID。
</ResponseField>

<ResponseField name="creditsUsed" type="number">
  本次生成扣除的积分数。
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.llmgenerator.com/api/v1/generate \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
          "url": "https://www.example.com",
          "options": {
            "maxUrls": 25,
            "generationMethod": "enhanced",
            "showFullText": true
          }
        }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api.llmgenerator.com/api/v1/generate', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      url: 'https://www.example.com',
      options: {
        maxUrls: 25,
        generationMethod: 'enhanced'
      }
    })
  });

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

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

  response = requests.post(
      'https://api.llmgenerator.com/api/v1/generate',
      headers={
          'Authorization': 'Bearer YOUR_API_KEY',
          'Content-Type': 'application/json'
      },
      json={
          'url': 'https://www.example.com',
          'options': {
              'maxUrls': 25,
              'generationMethod': 'enhanced'
          }
      }
  )

  data = response.json()
  ```
</RequestExample>

<ResponseExample>
  ```json Success Response theme={null}
  {
    "jobId": "550e8400-e29b-41d4-a716-446655440000",
    "status": "completed",
    "progress": 100,
    "message": "File generated successfully",
    "fileUrl": "https://api.llmgenerator.com/api/v1/file/site_xxxxx",
    "fullTextUrl": "https://api.llmgenerator.com/api/v1/file/site_xxxxx?full=true",
    "siteId": "site_xxxxx",
    "creditsUsed": 50
  }
  ```

  ```json Insufficient Credits (402) theme={null}
  {
    "message": "Insufficient credits. Required: 50, Available: 10. Please purchase more credits to continue."
  }
  ```
</ResponseExample>
