---
title: &quot;通过 RunAPI 在龙虾 (OpenClaw) 中使用 DeepSeek — 大模型API 指南&quot;
url: &quot;https://runapi.ai/zh-CN/openclaw-deepseek.md&quot;
canonical: &quot;https://runapi.ai/zh-CN/openclaw-deepseek&quot;
locale: &quot;zh-CN&quot;
model: &quot;deepseek&quot;
---

# 在 OpenClaw 中使用 DeepSeek。

DeepSeek V4 通过 RunAPI 同时提供 OpenAI 兼容和 Anthropic 兼容协议。Flash 主打速度，Pro 主打质量。内置推理模式通过一个请求参数激活——无需单独的模型 slug。RunAPI 以官方 DeepSeek 费率的 50% 对 DeepSeek token 定价。

## API example

```bash
curl -X POST https://runapi.ai/v1/chat/completions \
  -H &quot;Authorization: Bearer $RUNAPI_API_KEY&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -d &#39;{
    &quot;model&quot;: &quot;deepseek-v4-pro&quot;,
    &quot;messages&quot;: [
      {&quot;role&quot;: &quot;system&quot;, &quot;content&quot;: &quot;You are a helpful coding assistant.&quot;},
      {&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: &quot;Write a Python function that finds the longest palindromic substring in O(n) time using Manacher algorithm.&quot;}
    ],
    &quot;stream&quot;: true,
    &quot;max_tokens&quot;: 4096
  }&#39;

```

### Response

```json
{
  &quot;id&quot;: &quot;chatcmpl-abc123&quot;,
  &quot;object&quot;: &quot;chat.completion&quot;,
  &quot;model&quot;: &quot;deepseek-v4-pro&quot;,
  &quot;choices&quot;: [
    {
      &quot;index&quot;: 0,
      &quot;message&quot;: {
        &quot;role&quot;: &quot;assistant&quot;,
        &quot;content&quot;: &quot;Here is Manacher&#39;s algorithm implementation...&quot;
      },
      &quot;finish_reason&quot;: &quot;stop&quot;
    }
  ],
  &quot;usage&quot;: {
    &quot;prompt_tokens&quot;: 42,
    &quot;completion_tokens&quot;: 356,
    &quot;total_tokens&quot;: 398
  }
}

```

## How it works

1. **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.
2. **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.
3. **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.

## Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `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 &quot;enabled&quot; to activate DeepSeek&#39;s built-in reasoning mode. |

## FAQ

### How do I switch from OpenAI to DeepSeek -- is it really a drop-in replacement?

Yes. DeepSeek V4 supports the OpenAI chat completions format. Point OpenClaw at RunAPI&#39;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.

### What are thinking tokens in DeepSeek and how do they affect cost?

When you enable reasoning (thinking.type set to enabled), DeepSeek generates additional &quot;thinking&quot; 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.

### What is the difference between deepseek-v4-flash and deepseek-v4-pro?

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.

### Does RunAPI route DeepSeek requests through China?

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.

### How does DeepSeek pricing on RunAPI compare to direct DeepSeek API pricing?

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.


## Links

- [OpenClaw 配置指南 →](https://runapi.ai/zh-CN/openclaw)
- [DeepSeek 模型 →](https://runapi.ai/zh-CN/models/deepseek)
- [Model catalog](https://runapi.ai/zh-CN/models)
- [API docs](https://runapi.ai/zh-CN/docs)
