vLLM 通过 OpenAI 兼容 HTTP API 提供开源模型服务,OpenClaw 支持自动模型发现和流式用量统计。
| 属性 | 值 |
|---|---|
| Provider ID | vllm |
| 认证 | VLLM_API_KEY(无认证服务器填任意非空值) |
| API | OpenAI 兼容(openai-completions) |
| 默认 Base URL | http://127.0.0.1:8000/v1 |
快速开始
export VLLM_API_KEY="vllm-local"{
agents: {
defaults: {
model: { primary: "vllm/your-model-id" },
},
},
}模型自动发现
设置 VLLM_API_KEY 且未显式配置 models.providers.vllm 时,OpenClaw 自动查询 GET http://127.0.0.1:8000/v1/models。
使用通配符保持动态发现:
{
agents: {
defaults: {
models: { "vllm/*": {} },
},
},
}显式配置
{
models: {
providers: {
vllm: {
baseUrl: "http://127.0.0.1:8000/v1",
apiKey: "${VLLM_API_KEY}",
api: "openai-completions",
request: { allowPrivateNetwork: true },
timeoutSeconds: 300,
models: [
{
id: "your-model-id",
name: "Local vLLM Model",
reasoning: false,
input: ["text"],
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
contextWindow: 128000,
maxTokens: 8192,
},
],
},
},
},
}Qwen 模型特殊配置
Qwen 模型通过 vLLM 服务时,thinking 控制需设置 params.qwenThinkingFormat:
"chat-template":发送chat_template_kwargs.enable_thinking"top-level":发送顶层enable_thinking标志
若 Qwen 工具调用以文本形式输出,可尝试:
{
agents: {
defaults: {
models: {
"vllm/Qwen-Qwen2.5-Coder-32B-Instruct": {
params: { extra_body: { tool_choice: "required" } },
},
},
},
},
}故障排查
- 私有网络访问需设置
request.allowPrivateNetwork: true - 慢速模型建议设置
timeoutSeconds: 300 - 工具调用渲染为文本:检查 vLLM 启动时的 tool-call parser 和 chat template
相关链接
- provider-sglang — 另一个本地 OpenAI 兼容服务器
- provider-inferrs — inferrs 本地服务器
- providers — 所有 provider 总览