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

# PDFMathTranslate Next

> 了解如何在 PDFMathTranslate Next 中选择 OpenAI Compatible engine，接入 siflow endpoint，翻译 PDF 并保留版式。

[PDFMathTranslate Next](https://github.com/PDFMathTranslate/PDFMathTranslate-next)（`pdf2zh-next`）用于翻译 PDF，同时保留版式、公式、表格和图片。它的 **OpenAI Compatible** engine 面向任意 OpenAI-compatible endpoint，因此可以接入 siflow endpoint。

本文默认模型为 `glm-5.2`；完整模型列表和价格请查看 [模型广场](https://console.siflow.cn/model-inference/models)。

## 配置

安装 CLI（`pip install pdf2zh-next`），在 [API 密钥](https://console.siflow.cn/model-inference/api_keys) 页面创建 API Key，然后选择 **OpenAI Compatible** engine 并接入 siflow endpoint：

```bash theme={null}
pdf2zh_next \
  --openaicompatible \
  --openai-compatible-model glm-5.2 \
  --openai-compatible-base-url https://api.siflow.cn/model-api/v1 \
  --openai-compatible-api-key "<Your API Key>" \
  --lang-in en --lang-out zh \
  input.pdf
```

| Flag                           | 值                                                                      |
| ------------------------------ | ---------------------------------------------------------------------- |
| `--openaicompatible`           | 选择 OpenAI-compatible engine；接入这类第三方 endpoint 时请使用它，而不是 `--openai`      |
| `--openai-compatible-model`    | 模型 ID，例如 `glm-5.2`                                                     |
| `--openai-compatible-base-url` | siflow OpenAI-compatible endpoint：`https://api.siflow.cn/model-api/v1` |
| `--openai-compatible-api-key`  | 创建的 API Key                                                            |
| `--lang-in` / `--lang-out`     | 源语言 / 目标语言代码，例如 `en` → `zh`                                            |

该工具设计上会保留公式、表格和图片，只翻译文本片段。可以使用 `--qps` 限制请求速率，使用 `--pages`（例如 `1-5`）翻译部分页面。

## 验证

翻译一页。工具会生成单语和双语 PDF，并打印 token usage，表示请求已到达 siflow endpoint：

```bash theme={null}
pdf2zh_next --openaicompatible \
  --openai-compatible-model glm-5.2 \
  --openai-compatible-base-url https://api.siflow.cn/model-api/v1 \
  --openai-compatible-api-key "<Your API Key>" \
  --lang-in en --lang-out zh --pages 1 --output out/ input.pdf

# → out/input.zh.mono.pdf , out/input.zh.dual.pdf
# → Total Token Usage: Total 4022, Prompt 1246, Completion 2776
```

翻译后的 PDF 会包含目标语言文本，同时保留数学公式。例如 `a^2 + b^2 = c^2` 在输出中保持不变。
