OpenAI-Compatible API
KTransformers 推理通过 SGLang-KT serving,因此应用层代码应尽量按 OpenAI-compatible endpoint 接入。
主要 Endpoint
使用:
POST /v1/chat/completions
常见请求字段:
| 字段 | 说明 |
|---|---|
model | 必须匹配启动服务时配置的 served model name。 |
messages | 带 role 和 content 的 chat messages。 |
temperature、top_p、max_tokens | 传给 serving runtime 的采样参数。 |
stream | 设为 true 时使用 Server-Sent Events 流式输出。 |
Model Name
手动启动时建议设置稳定的 served model name:
python -m sglang.launch_server \
--model-path /path/to/model \
--served-model-name my-model \
--kt-weight-path /path/to/kt-weights \
--kt-method FP8
随后请求里使用 my-model。
兼容性说明
- 应用集成优先使用 OpenAI client 路径。
- 模型特定的 tool calling 或 reasoning parser,应使用精确模型页或 registry default 中的 parser 参数。
- 如果输出格式和非 KT SGLang 部署不同,先检查 tokenizer chat template、served model name、parser options 和模型特定启动参数。