OPENCLAW + CLAUDE

Use Claude in OpenClaw.

Anthropic Claude provides Opus 4.8 for maximum capability (200K context, extended thinking), Sonnet 4.6 for balanced performance, and Haiku 4.5 for speed. OpenClaw calls Claude through RunAPI's OpenAI-compatible endpoint at 50% of Anthropic's official per-token rate — same models, same output, half the cost.

one API key · OpenAI-compatible endpoint · per-token billing at 50% off
Use RunAPI to send a Claude chat completion request from OpenClaw.

Requirements:
- Call the RunAPI chat completions endpoint at https://runapi.ai/v1/chat/completions
- Set model to "claude-opus-4.8"
- Use the RUNAPI_API_KEY environment variable for authorization
- The response is synchronous — the assistant message is returned directly in the response body
- For streaming, set "stream": true to receive 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
  }
}
Copy the curl command to test claude
HOW IT WORKS

Use Claude in OpenClaw in three steps

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.

export RUNAPI_API_KEY=runapi_xxx
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 "stream" true if you want token-by-token SSE output.

POST /v1/chat/completions
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.

usage.total_tokens: 111
PARAMETERS

Claude API parameters (OpenAI-compatible)

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.

What is Claude on OpenClaw?

Claude is Anthropic's LLM family -- Opus 4.8 with 200K context and extended thinking for deep analysis, Sonnet 4.6 for everyday coding and writing, and Haiku 4.5 for fast cheap tasks. Through RunAPI, OpenClaw agents call Claude at 50% of the official Anthropic per-token rate using the same OpenAI-compatible endpoint and API key used for GPT and Gemini. Prompt caching is supported to cut costs further on repeated context.

Claude use cases

Agentic coding with tool use

Use Claude with function calling and MCP (Model Context Protocol) for automated coding workflows -- code generation, pull request reviews, multi-file refactors, and test writing with tool-assisted context gathering.

Long document analysis with 200K context

Feed entire codebases, legal contracts, or research papers into Claude Opus 4.8's 200K token context window for analysis, summarization, and question answering without chunking.

Enterprise automation with audit trails

Build automated workflows where Claude processes documents, extracts data, and makes decisions, with token usage tracking for cost transparency and billing audit trails.

FAQ

Claude + OpenClaw questions

OpenClaw general setup

Not configured yet? Start with the RunAPI setup guide for OpenClaw.

OpenClaw setup guide →

Claude model catalog

See all Claude variants, per-token pricing, and context window details.

Claude models →

Try Claude in OpenClaw today.

Get a free RunAPI key, paste the prompt into OpenClaw, and start using Claude at 50% of the official Anthropic rate.