Providers

ds4

ds4 透過本機 Metal 後端提供 DeepSeek V4 Flash,並具備 OpenAI 相容的 /v1 API。OpenClaw 透過通用的 openai-completions 提供者系列連線到 ds4。

ds4 不是內建的 OpenClaw 提供者外掛。請在 models.providers.ds4 下設定,然後選取 ds4/deepseek-v4-flash

屬性
提供者 ID ds4
外掛 無(僅設定)
API OpenAI 相容的 Chat Completions(openai-completions
基礎 URL http://127.0.0.1:18000/v1(建議)
模型 ID deepseek-v4-flash
工具呼叫 OpenAI 風格的 tools / tool_calls
推理 DeepSeek 風格的 thinkingreasoning_effort

需求

  • 支援 Metal 的 macOS。
  • 可正常運作的 ds4 checkout,包含 ds4-server 和 DeepSeek V4 Flash GGUF 檔案。
  • 足夠支援你選擇內容的記憶體;較大的 --ctx 值會在伺服器啟動時配置更多 KV 記憶體。

快速開始

  • 啟動 ds4-server

    <DS4_DIR> 替換為你的 ds4 checkout 路徑。

    bash
    <DS4_DIR>/ds4-server \  --model <DS4_DIR>/ds4flash.gguf \  --host 127.0.0.1 \  --port 18000 \  --ctx 32768 \  --tokens 128
  • 驗證 OpenAI 相容端點

    bash
    curl http://127.0.0.1:18000/v1/models

    回應應包含 deepseek-v4-flash

  • 加入 OpenClaw 提供者設定

    加入完整設定中的設定,然後執行一次性模型檢查:

    bash
    openclaw infer model run \  --local \  --model ds4/deepseek-v4-flash \  --thinking off \  --prompt "Reply with exactly: openclaw-ds4-ok" \  --json
  • 完整設定

    當 ds4 已在 127.0.0.1:18000 上執行時,使用此設定。

    json5
    {  agents: {    defaults: {      model: { primary: "ds4/deepseek-v4-flash" },      models: {        "ds4/deepseek-v4-flash": {          alias: "DS4 local",        },      },    },  },  models: {    mode: "merge",    providers: {      ds4: {        baseUrl: "http://127.0.0.1:18000/v1",        apiKey: "ds4-local",        api: "openai-completions",        timeoutSeconds: 300,        models: [          {            id: "deepseek-v4-flash",            name: "DeepSeek V4 Flash (ds4)",            reasoning: true,            input: ["text"],            cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },            contextWindow: 32768,            maxTokens: 128,            compat: {              supportsUsageInStreaming: true,              supportsReasoningEffort: true,              maxTokensField: "max_tokens",              supportsStrictMode: false,              thinkingFormat: "deepseek",              supportedReasoningEfforts: ["low", "medium", "high", "xhigh"],            },          },        ],      },    },  },}

    contextWindowds4-server --ctx 保持一致。除非你刻意想讓 OpenClaw 請求比伺服器預設值更少的輸出,否則讓 maxTokens--tokens 保持一致。

    隨需啟動

    OpenClaw 可以只在選取 ds4/... 模型時啟動 ds4。將 localService 加到同一個提供者項目:

    json5
    {  models: {    providers: {      ds4: {        baseUrl: "http://127.0.0.1:18000/v1",        apiKey: "ds4-local",        api: "openai-completions",        timeoutSeconds: 300,        localService: {          command: "<DS4_DIR>/ds4-server",          args: [            "--model",            "<DS4_DIR>/ds4flash.gguf",            "--host",            "127.0.0.1",            "--port",            "18000",            "--ctx",            "32768",            "--tokens",            "128",          ],          cwd: "<DS4_DIR>",          healthUrl: "http://127.0.0.1:18000/v1/models",          readyTimeoutMs: 300000,          idleStopMs: 0,        },        models: [          {            id: "deepseek-v4-flash",            name: "DeepSeek V4 Flash (ds4)",            reasoning: true,            input: ["text"],            cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },            contextWindow: 32768,            maxTokens: 128,            compat: {              supportsUsageInStreaming: true,              supportsReasoningEffort: true,              maxTokensField: "max_tokens",              supportsStrictMode: false,              thinkingFormat: "deepseek",              supportedReasoningEfforts: ["low", "medium", "high", "xhigh"],            },          },        ],      },    },  },}

    command 必須是絕對可執行檔路徑。不會使用 shell 查找和 ~ 展開。請參閱本機模型服務以了解每個 localService 欄位。

    Think Max

    ds4 只有在兩者皆為 true 時才會套用 Think Max:

    • ds4-server--ctx 393216 或更高值啟動。
    • 請求使用 reasoning_effort: "max"(或等效的 ds4 effort 欄位)。

    如果你執行這麼大的內容,請同時更新伺服器旗標和 OpenClaw 模型中繼資料:

    json5
    {  contextWindow: 393216,  maxTokens: 384000,  compat: {    supportsUsageInStreaming: true,    supportsReasoningEffort: true,    maxTokensField: "max_tokens",    supportsStrictMode: false,    thinkingFormat: "deepseek",    supportedReasoningEfforts: ["low", "medium", "high", "xhigh", "max"],  },}

    測試

    直接 HTTP 檢查,繞過 OpenClaw:

    bash
    curl http://127.0.0.1:18000/v1/chat/completions \  -H 'content-type: application/json' \  -d '{"model":"deepseek-v4-flash","messages":[{"role":"user","content":"Reply with exactly: ds4-ok"}],"max_tokens":16,"stream":false,"thinking":{"type":"disabled"}}'

    OpenClaw 模型路由(與快速開始檢查相同):

    bash
    openclaw infer model run \  --local \  --model ds4/deepseek-v4-flash \  --thinking off \  --prompt "Reply with exactly: openclaw-ds4-ok" \  --json

    完整 agent 和工具呼叫煙霧測試,內容至少為 32768:

    bash
    openclaw agent \  --local \  --session-id ds4-tool-smoke \  --model ds4/deepseek-v4-flash \  --thinking off \  --message "Use the shell command pwd once, then reply exactly: tool-ok <output>" \  --json \  --timeout 240

    預期結果:

    • executionTrace.winnerProviderds4
    • executionTrace.winnerModeldeepseek-v4-flash
    • toolSummary.calls 至少為 1
    • finalAssistantVisibleTexttool-ok 開頭

    疑難排解

    curl /v1/models 無法連線

    ds4 未執行,或未綁定到 baseUrl 中的主機/連接埠。啟動 ds4-server,然後重試:

    bash
    curl http://127.0.0.1:18000/v1/models
    500 prompt exceeds context

    設定的 --ctx 對 OpenClaw 回合來說太小。提高 ds4-server --ctx,然後更新 models.providers.ds4.models[].contextWindow 以保持一致。含工具的完整 agent 回合需要比直接單訊息 curl 請求多得多的內容。

    Think Max 未啟用

    ds4 只有在 --ctx 至少為 393216 且請求要求 reasoning_effort: "max" 時才會使用 Think Max。較小的內容會退回高推理。

    第一個請求很慢

    ds4 有冷啟動的 Metal 駐留和模型暖機階段。當 OpenClaw 隨需啟動伺服器時,請設定 localService.readyTimeoutMs: 300000

    相關

    Was this useful?
    On this page

    On this page