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

# Chat2Graph

> 了解如何在 Chat2Graph 的 .env 中通过 LiteLLM 配置 LLM_ENDPOINT，接入 siflow endpoint，为图原生智能体系统提供算秩模型。

[Chat2Graph](https://github.com/TuGraph-family/chat2graph) 是蚂蚁 TuGraph 开源的图原生智能体系统（graph + agent）。它通过 LiteLLM 调用大模型，`LLM_ENDPOINT` 可指向任意 OpenAI 兼容服务，因此可以接入算秩模型推理服务。

本文以 `glm-5.2` 为例。完整模型清单与价格见 [模型广场](https://console.siflow.cn/model-inference/models)。

本文仅说明如何将算秩配置为 Chat2Graph 的 LLM。部分图检索能力还需要 Embedding 模型，请按照 Chat2Graph 官方文档另行配置。

## 配置

在 [API 密钥](https://console.siflow.cn/model-inference/api_keys) 页面创建一个 API Key。复制 `.env.template` 为 `.env`，填写：

```bash theme={null}
MODEL_PLATFORM_TYPE=LITELLM
LLM_NAME=openai/glm-5.2
LLM_ENDPOINT=https://api.siflow.cn/model-api/v1
LLM_APIKEY=<您的 API Key>
```

| 字段                    | 说明                                                                            |
| --------------------- | ----------------------------------------------------------------------------- |
| `MODEL_PLATFORM_TYPE` | `LITELLM`                                                                     |
| `LLM_NAME`            | `openai/<模型 ID>` —— `openai/` 前缀让 LiteLLM 按 OpenAI 兼容处理，如 `openai/glm-5.2`    |
| `LLM_ENDPOINT`        | siflow OpenAI 兼容端点（base URL，含 `/v1`）：`https://api.siflow.cn/model-api/v1`     |
| `LLM_APIKEY`          | 您在 [API 密钥](https://console.siflow.cn/model-inference/api_keys) 页面创建的 API Key |

## 验证

构建并启动（`./bin/build.sh` 后 `./bin/start.sh`），打开 Web 界面（默认 `http://localhost:5010/`）发送一条消息，能正常回复即接入成功。

底层由 LiteLLM 按上述配置发起请求；等价的最小校验：

```python theme={null}
import litellm
r = litellm.completion(
    model="openai/glm-5.2",
    api_base="https://api.siflow.cn/model-api/v1",
    api_key="<您的 API Key>",
    messages=[{"role": "user", "content": "Reply with exactly: OK"}],
)
print(r.choices[0].message.content)  # → OK
```

## 常见问题

* **`LLM_NAME` 必须带 `openai/` 前缀**：这样 LiteLLM 才会把它当作 OpenAI 兼容供应商、走 `LLM_ENDPOINT`，而不是去推断具体厂商。
* **`LLM_ENDPOINT` 填 base URL（含 `/v1`）**。
* 模型 ID 以 [模型广场](https://console.siflow.cn/model-inference/models) 为准。
