OPENCLAW + DEEPSEEK

在 OpenClaw 中使用 DeepSeek。

DeepSeek V4 透過 RunAPI 同時支援相容 OpenAI 與相容 Anthropic 的協定。Flash 追求速度,Pro 追求品質。內建推理模式透過請求參數啟動——無需獨立的模型 slug。RunAPI 的 DeepSeek token 定價為 DeepSeek 官方費率的 50%。

一個 API key · OpenAI + Anthropic 協定 · 串流支援
Use RunAPI to call DeepSeek V4 Pro through the OpenAI-compatible chat completions endpoint.

Requirements:
- Call the RunAPI chat completions endpoint at https://runapi.ai/v1/chat/completions
- Set model to "deepseek-v4-pro"
- Use the RUNAPI_API_KEY environment variable for authorization
- The response is synchronous — the reply streams back as SSE events or returns as a single JSON object depending on the stream parameter
- To enable reasoning, set thinking.type to "enabled" in the request body
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
  }
}
複製 curl 指令進行測試 deepseek
運作原理

三步驟在 OpenClaw 中使用 DeepSeek

1

將 RunAPI 設定為供應商

設定 RUNAPI_API_KEY 環境變數。在 OpenClaw 中,將 RunAPI 加為相容 OpenAI 的供應商,baseUrl 設為 https://runapi.ai/v1。DeepSeek 使用與 GPT 或 Claude 相同的供應商——無需獨立的供應商項目。

export RUNAPI_API_KEY=runapi_xxx
2

選擇 DeepSeek 模型

將 model 設為 deepseek-v4-pro 追求品質,或 deepseek-v4-flash 追求速度。兩者皆使用 /v1/chat/completions 端點。若要啟用推理,傳入 thinking.type 設為 enabled——無需更改模型 slug。

model: deepseek-v4-pro
3

串流回應

OpenClaw 以 OpenAI chat completions 格式的 SSE 串流接收回應。最終事件中回報 token 使用量以確保計費透明。無論透過 RunAPI 使用 DeepSeek、GPT 或 Claude,格式皆相同。

stream: true
參數

DeepSeek chat completions 參數

參數 類型 說明
model string 必填。deepseek-v4-pro 或 deepseek-v4-flash。
messages array 必填。訊息物件陣列,每個物件包含 role(system、user、assistant)與 content 欄位。
stream boolean 選填。設為 true 啟用 SSE 串流。預設為 false。
max_tokens integer 選填。生成的最大 token 數量。
temperature number 選填。取樣溫度,介於 0 到 2 之間。較低的值更具確定性。
thinking object 選填。將 type 設為 "enabled" 以啟動 DeepSeek 的內建推理模式。

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。

FAQ

DeepSeek + OpenClaw 常見問題

OpenClaw 通用設定

尚未設定?請從 OpenClaw 的 RunAPI 設定指南開始。

OpenClaw 設定指南 →

DeepSeek 模型目錄

查看 DeepSeek V4 變體、定價與 API 文件。

DeepSeek models →

立即在 OpenClaw 中試用 DeepSeek。

取得免費 RunAPI key,在 OpenClaw 中將 model 設為 deepseek-v4-pro,以最低 token 價格開始使用推理編碼。