OpenClaw で Claude を使う。
Anthropic Claude は、最大の能力(200K コンテキスト、拡張思考)のための Opus 4.8、バランスの取れたパフォーマンスのための Sonnet 4.6、スピードのための Haiku 4.5 を提供します。OpenClaw は RunAPI の OpenAI 互換エンドポイント経由で Anthropic 公式のトークン単価の 50% で Claude を呼び出します——同じモデル、同じ出力、半分のコスト。
RunAPI を使って OpenClaw から Claude のチャット補完リクエストを送信します。
要件:
- RunAPI のチャット補完エンドポイント https://runapi.ai/v1/chat/completions を呼び出します
- model を "claude-opus-4.8" に設定します
- 認証には RUNAPI_API_KEY 環境変数を使用します
- レスポンスは同期的です——assistant メッセージはレスポンスボディで直接返されます
- ストリーミングには "stream": true を設定して server-sent events を受け取ります
curl -X POST https://runapi.ai/v1/chat/completions \
-H "Authorization: Bearer $RUNAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-4.8",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Explain the difference between a mutex and a semaphore in three sentences."}
]
}'
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"model": "claude-opus-4.8",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "A mutex is a locking mechanism that allows only one thread to access a resource at a time..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 24,
"completion_tokens": 87,
"total_tokens": 111
}
}
OpenClaw で Claude を使う3ステップ
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.
export RUNAPI_API_KEY=runapi_xxx
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 "stream" true if you want token-by-token SSE output.
POST /v1/chat/completions
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.
usage.total_tokens: 111
Claude API パラメータ(OpenAI 互換)
| パラメータ | 型 | 説明 |
|---|---|---|
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. |
OpenClaw上のClaudeとは?
ClaudeはAnthropicのLLMファミリーです——Opus 4.8は200Kコンテキストと拡張思考による深い分析・Sonnet 4.6は日常的なコーディングと執筆・Haiku 4.5は高速低コストタスク向けです。RunAPIを通じてOpenClaw agentは公式Anthropicの1トークンあたり価格の50%でClaudeを呼び出し、繰り返しコンテキストのシーンでコストをさらに削減するプロンプトキャッシングをサポートします。
Claudeの活用例
ツール使用によるAgentic Coding
Claudeの関数呼び出しとMCP(Model Context Protocol)を使って自動化されたコーディングワークフローを構築します——コード生成・PRレビュー・マルチファイルリファクタリング・テスト作成をツール補助のコンテキスト収集で行います。
200Kコンテキストによる長文書分析
コードベース全体・法的契約・研究論文をClaude Opus 4.8の200Kトークンコンテキストウィンドウに入力して分析・要約・Q&Aを行い、チャンキング不要です。
監査証跡付きエンタープライズ自動化
Claudeがドキュメントを処理・データを抽出・意思決定する自動化ワークフローを構築し、コスト透明性と請求監査のためにトークン使用量を追跡します。
Claude + OpenClaw のよくある質問
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.
RunAPI charges 50% of Anthropic'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.
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.
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.
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.
今すぐ OpenClaw で Claude を試す。
無料の RunAPI キーを取得し、プロンプトを OpenClaw に貼り付けて、Anthropic 公式料金の 50% で Claude を使い始めましょう。