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

# 在 OpenClaw 中使用 Claude。

Anthropic Claude 提供 Opus 4.8 以获得最强能力（200K 上下文、扩展思考）、Sonnet 4.6 以获得均衡性能、Haiku 4.5 以获得速度。OpenClaw 通过 RunAPI 的 OpenAI 兼容端点以 Anthropic 官方每 token 费率的 50% 调用 Claude——相同的模型、相同的输出、一半的成本。

## 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;claude-opus-4.8&quot;,
    &quot;max_tokens&quot;: 1024,
    &quot;messages&quot;: [
      {&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: &quot;Explain the difference between a mutex and a semaphore in three sentences.&quot;}
    ]
  }&#39;

```

### Response

```json
{
  &quot;id&quot;: &quot;chatcmpl-abc123&quot;,
  &quot;object&quot;: &quot;chat.completion&quot;,
  &quot;model&quot;: &quot;claude-opus-4.8&quot;,
  &quot;choices&quot;: [
    {
      &quot;index&quot;: 0,
      &quot;message&quot;: {
        &quot;role&quot;: &quot;assistant&quot;,
        &quot;content&quot;: &quot;A mutex is a locking mechanism that allows only one thread to access a resource at a time...&quot;
      },
      &quot;finish_reason&quot;: &quot;stop&quot;
    }
  ],
  &quot;usage&quot;: {
    &quot;prompt_tokens&quot;: 24,
    &quot;completion_tokens&quot;: 87,
    &quot;total_tokens&quot;: 111
  }
}

```

## How it works

1. **Configure RunAPI** — Set the RUNAPI_API_KEY environment variable. If you already configured RunAPI as an OpenClaw provider, the same key works for Claude — no extra setup needed. OpenClaw uses the openai-completions API mode pointed at https://runapi.ai/v1.
2. **Call Claude** — Send a POST request to /v1/chat/completions with model set to claude-opus-4.8. Include a messages array with at least one user message. Set max_tokens to control response length. Add &quot;stream&quot; true if you want token-by-token SSE output.
3. **Read the response** — The endpoint returns the assistant message synchronously — no task polling needed. The response includes token usage counts for billing transparency. Streaming responses arrive as SSE events, each containing a delta chunk.

## Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `model` | `string` | Required. claude-opus-4.8, claude-sonnet-4.6, claude-haiku-4.5, or any Claude variant listed in the RunAPI catalog. |
| `messages` | `array` | Required. Array of message objects with role (system, user, assistant) and content fields. |
| `max_tokens` | `integer` | Maximum number of tokens in the response. Defaults vary by model — set explicitly for predictable billing. |
| `stream` | `boolean` | When true, returns server-sent events with incremental token deltas instead of a single JSON response. |
| `temperature` | `float` | Sampling temperature between 0 and 1. Lower values produce more deterministic output. |
| `top_p` | `float` | Nucleus sampling cutoff. Alternative to temperature — use one or the other, not both. |

## FAQ

### Can I call Claude from OpenClaw through RunAPI?

Yes. Configure RunAPI as an OpenAI-compatible provider in OpenClaw with base URL https://runapi.ai/v1. Set model to claude-opus-4.8 or any other Claude variant. The same RUNAPI_API_KEY handles chat, image, video, and music models.

### How much does the Claude API actually cost with prompt caching?

RunAPI charges 50% of Anthropic&#39;s official rate. Opus 4.8 is $7.50/$37.50 per million input/output tokens through RunAPI versus $15/$75 direct. With prompt caching enabled, cached input tokens cost even less. Check the RunAPI pricing page for exact rates.

### What are Claude&#39;s rate limits and how do I avoid hitting them?

Rate limits depend on your RunAPI plan tier and are measured in requests per minute (RPM) and tokens per minute (TPM). Use prompt caching to reduce input token volume on repeated context. For high-throughput workloads, contact RunAPI for increased limits.

### Can I use extended thinking with Claude through RunAPI?

Extended thinking is available on the Anthropic Messages API endpoint at /v1/messages. When using the OpenAI-compatible /v1/chat/completions endpoint from OpenClaw, standard completion parameters apply. For extended thinking, call /v1/messages directly with the thinking parameter.

### Which Claude model should I choose for coding tasks in OpenClaw?

Opus 4.8 for complex multi-file refactors and architecture decisions. Sonnet 4.6 for everyday coding -- pull request reviews, test generation, and bug fixes. Haiku 4.5 for fast autocomplete and inline suggestions where latency matters more than depth.


## Links

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