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

# 生成文档

> 根据自然语言生成 PDF、DOCX、PPTX、XLSX 或 CSV 文档。

根据自然语言提示生成结构化文档。支持 PDF、DOCX、PPTX、XLSX 和 CSV 格式。

## 身份验证

需要 Bearer 令牌。参见[身份验证](/api-reference/authentication)。

## 请求正文

<ParamField body="prompt" type="string" required>
  要生成的文档的描述。
</ParamField>

<ParamField body="format" type="string" default="pdf">
  输出格式。可选值：`pdf`、`docx`、`pptx`、`xlsx`、`csv`。
</ParamField>

## 请求示例

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST https://www.hitheo.ai/api/v1/documents \
    -H "Authorization: Bearer $THEO_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "prompt": "Create a Q1 2026 sales report with executive summary and charts",
      "format": "pdf"
    }'
  ```

  ```typescript SDK theme={null}
  const res = await theo.documents({
    prompt: "Create a Q1 2026 sales report with executive summary and charts",
    format: "pdf",
  });

  console.log(res.title);        // "Q1 2026 Sales Report"
  console.log(res.download_url); // Presigned download URL
  console.log(res.content);      // Document text content
  ```
</CodeGroup>

## 响应

<ResponseField name="id" type="string">
  唯一文档 ID（以 `doc_` 为前缀）。
</ResponseField>

<ResponseField name="created" type="string">
  ISO 8601 时间戳。
</ResponseField>

<ResponseField name="format" type="string">
  输出格式（例如 `"pdf"`）。
</ResponseField>

<ResponseField name="title" type="string">
  自动生成的文档标题。
</ResponseField>

<ResponseField name="download_url" type="string | null">
  用于下载文档文件的预签名 URL。若文件仍在生成中，则可能为 `null`。
</ResponseField>

<ResponseField name="size_bytes" type="integer | null">
  文件大小（字节）。
</ResponseField>

<ResponseField name="content" type="string">
  生成文档的文本内容。
</ResponseField>

<ResponseField name="usage" type="object">
  <Expandable title="Usage object">
    <ResponseField name="cost_cents" type="number">费用（美分）。</ResponseField>
  </Expandable>
</ResponseField>

### 响应示例

```json theme={null}
{
  "id": "doc_abc123",
  "created": "2026-04-10T12:00:00Z",
  "format": "pdf",
  "title": "Q1 2026 Sales Report",
  "download_url": "https://artifacts.hitheo.ai/docs/abc123.pdf?token=...",
  "size_bytes": 245760,
  "content": "# Q1 2026 Sales Report\n\n## Executive Summary\n...",
  "usage": { "cost_cents": 0.12 }
}
```

## 错误

| 状态码 | 代码 | 描述 |
| - | - | - |
| 400 | `missing_prompt` | 缺少必需的 `prompt` 参数 |
| 400 | `invalid_format` | 不支持的格式。支持的格式：`pdf`、`docx`、`pptx`、`xlsx`、`csv` |
| 401 | `invalid_api_key` | 缺少 API 密钥或密钥无效 |
| 429 | `rate_limit_exceeded` | 请求次数过多 |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.