在 OpenClaw 中使用 DeepSeek。
DeepSeek V4 通过 RunAPI 同时提供 OpenAI 兼容和 Anthropic 兼容协议。Flash 主打速度,Pro 主打质量。内置推理模式通过一个请求参数激活——无需单独的模型 slug。RunAPI 以官方 DeepSeek 费率的 50% 对 DeepSeek token 定价。
使用 RunAPI 通过 OpenAI 兼容的聊天补全端点调用 DeepSeek V4 Pro。
要求:
- 调用 RunAPI 聊天补全端点 https://runapi.ai/v1/chat/completions
- 将 model 设置为 "deepseek-v4-pro"
- 使用 RUNAPI_API_KEY 环境变量进行授权
- 响应是同步的——根据 stream 参数,回复以 SSE 事件流式返回,或作为单个 JSON 对象返回
- 如需启用推理,在请求体中将 thinking.type 设置为 "enabled"
curl -X POST https://runapi.ai/v1/chat/completions \
-H "Authorization: Bearer $RUNAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-pro",
"messages": [
{"role": "system", "content": "You are a helpful coding assistant."},
{"role": "user", "content": "Write a Python function that finds the longest palindromic substring in O(n) time using Manacher algorithm."}
],
"stream": true,
"max_tokens": 4096
}'
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"model": "deepseek-v4-pro",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Here is Manacher's algorithm implementation..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 42,
"completion_tokens": 356,
"total_tokens": 398
}
}
三步在 OpenClaw 中使用 DeepSeek
Configure RunAPI as provider
Set the RUNAPI_API_KEY environment variable. In OpenClaw, add RunAPI as an OpenAI-compatible provider with baseUrl https://runapi.ai/v1. DeepSeek works through the same provider you use for GPT or Claude — no separate provider entry needed.
export RUNAPI_API_KEY=runapi_xxx
Select a DeepSeek model
Set the model to deepseek-v4-pro for quality or deepseek-v4-flash for speed. Both use the /v1/chat/completions endpoint. To enable reasoning, pass thinking.type set to enabled — no model slug change required.
model: deepseek-v4-pro
Stream the response
OpenClaw receives the response as an SSE stream in OpenAI chat completions format. Token usage is reported in the final event for billing transparency. The same format works whether you use DeepSeek, GPT, or Claude through RunAPI.
stream: true
DeepSeek 聊天补全参数
| 参数 | 类型 | 说明 |
|---|---|---|
model |
string |
Required. deepseek-v4-pro or deepseek-v4-flash. |
messages |
array |
Required. Array of message objects with role (system, user, assistant) and content fields. |
stream |
boolean |
Optional. Set to true for SSE streaming. Default false. |
max_tokens |
integer |
Optional. Maximum number of tokens to generate. |
temperature |
number |
Optional. Sampling temperature between 0 and 2. Lower values are more deterministic. |
thinking |
object |
Optional. Set type to "enabled" to activate DeepSeek's built-in reasoning mode. |
OpenClaw 上的 DeepSeek 是什么?
DeepSeek V4 是 OpenAI 兼容的 LLM,在 OpenClaw 中可作为 GPT 的直接替代品——只需修改模型名称,其余配置不变。它通过请求参数支持内置的思维链推理,RunAPI 以 DeepSeek 已经很低的官方价格的 50% 提供,成为推理能力模型中单 token 成本最低的选择。
DeepSeek 使用场景
高并发应用的低成本替代方案
将日处理数千次请求的应用中的 GPT 或 Claude 替换为 DeepSeek。通过 RunAPI 以 DeepSeek 已低价格的 50% 计费,token 成本大幅下降,无需修改 OpenAI SDK 代码。
带可见思维链的推理密集型任务
为数学、逻辑、代码调试或规划任务启用思考模式,逐步推理有助于提高准确率。思考 token 在响应中可见,适合构建展示模型推理过程的 UI。
代码生成与调试
使用 DeepSeek V4 Pro 完成代码生成、算法实现和调试。在编程基准测试中表现优秀,单 token 成本远低于 GPT-5.5。
DeepSeek + OpenClaw 常见问题
Yes. DeepSeek V4 supports the OpenAI chat completions format. Point OpenClaw at RunAPI's /v1 base URL, change the model parameter to deepseek-v4-pro or deepseek-v4-flash, and the rest of your config stays the same. No code changes beyond the model name.
When you enable reasoning (thinking.type set to enabled), DeepSeek generates additional "thinking" tokens that show its chain-of-thought process. These tokens count as output tokens and are billed accordingly. They improve accuracy on complex tasks but increase total token usage.
Flash prioritizes speed with lower latency and cost. Pro prioritizes quality with better performance on complex reasoning, coding, and multi-step tasks. Both use the same endpoint and accept the same parameters.
No. RunAPI proxies DeepSeek through its own infrastructure. Your requests do not route through Chinese data centers, and your API key is never shared with DeepSeek directly.
RunAPI prices DeepSeek tokens at 50% of official DeepSeek rates. DeepSeek is already one of the lowest-cost LLM providers, so through RunAPI you get the lowest per-token price available for a reasoning-capable model. Billing is per-token with no subscription or minimum spend.
立即在 OpenClaw 中试用 DeepSeek。
免费获取 RunAPI 密钥,在 OpenClaw 中将 model 设置为 deepseek-v4-pro,以当前最低的 token 价格开始带推理的编码。