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 的直接替代品——更改模型名稱,其他一切保持不變。它透過請求參數支援內建的思維鏈推理(無需單獨的模型 slug),而 RunAPI 以官方 DeepSeek 費率的 50% 定價,使其成為具備推理能力的模型中每 token 成本最低的選項。

DeepSeek 使用情境

高量應用程式的低成本替代方案

為每日處理數千個請求的應用程式,用 DeepSeek 替換 GPT 或 Claude。透過 RunAPI 以 DeepSeek 已低廉費率的 50% 計算,在不更改 OpenAI SDK 程式碼的前提下,大幅降低 token 成本。

含可見思維鏈的推理密集任務

為數學、邏輯、程式碼除錯或規劃任務啟用思考模式,逐步推理能提升準確性。思考 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 價格開始使用推理編碼。