/install runapi-claude
Claude on RunAPI
Use the official Anthropic SDK (Python, TypeScript, Ruby) — or any
Anthropic-compatible HTTP client — and switch the base URL to
https://runapi.ai. The endpoint speaks the Anthropic Messages protocol
(POST /v1/messages), so no client code changes beyond base_url and
api_key.
Setup
ANTHROPIC_API_KEY=YOUR_RUNAPI_TOKEN
ANTHROPIC_BASE_URL=https://runapi.ai
Get a RunAPI API Key at \x3Chttps://runapi.ai/api_keys>.
| Language | Init |
|---|---|
| Python | anthropic.Anthropic(api_key=..., base_url="https://runapi.ai") |
| TypeScript | new Anthropic({ apiKey: ..., baseURL: "https://runapi.ai" }) |
| Ruby | Anthropic::Client.new(api_key: ..., base_url: "https://runapi.ai") |
| curl | POST https://runapi.ai/v1/messages with x-api-key: header |
x-api-key and Authorization: Bearer ... both work; the SDK uses
x-api-key by default.
Core recipe — non-streaming message
import anthropic
client = anthropic.Anthropic(
api_key="YOUR_RUNAPI_TOKEN",
base_url="https://runapi.ai",
)
message = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
system="You are a helpful assistant.",
messages=[{"role": "user", "content": "Explain quantum computing simply."}],
)
print(message.content[0].text)
print(message.usage) # input_tokens / output_tokens
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: "YOUR_RUNAPI_TOKEN",
baseURL: "https://runapi.ai",
});
const message = await client.messages.create({
model: "claude-sonnet-4-6",
max_tokens: 1024,
system: "You are a helpful assistant.",
messages: [{ role: "user", content: "Explain quantum computing simply." }],
});
max_tokens is required by the Anthropic API.
Streaming
with client.messages.stream(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": "Write a haiku about coding."}],
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)
const stream = await client.messages.stream({
model: "claude-sonnet-4-6",
max_tokens: 1024,
messages: [{ role: "user", content: "Write a haiku about coding." }],
});
for await (const event of stream) {
if (event.type === "content_block_delta") {
process.stdout.write(event.delta.text);
}
}
Streaming runs through a regional edge proxy so the request does not hold a
Rails/Puma thread. Long generations (extended thinking, large max_tokens)
should always stream.
Vision / multimodal
{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": [
{ "type": "text", "text": "What is in this image?" },
{
"type": "image_url",
"image_url": { "url": "https://example.com/image.png" }
}
]
}
]
}
Image input uses the standard Anthropic image_url block. URLs must be
publicly fetchable.
Tool use / web search / reasoning
{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"reasoning_effort": "high",
"include_thoughts": true,
"tools": [
{ "type": "function", "function": { "name": "googleSearch" } }
],
"messages": [
{ "role": "user", "content": "What's the latest on Claude 4.7?" }
]
}
reasoning_effort:"low"or"high". Supported on every model below.include_thoughts: returns reasoning content. Onlyclaude-sonnet-4-5-20250929andclaude-sonnet-4-6support this.- Web access uses a
googleSearchfunction tool. - Set header
anthropic-beta: interleaved-thinking-2025-05-14to interleave thinking blocks with output.
Token counting
curl -X POST "https://runapi.ai/v1/messages/count_tokens" \
-H "x-api-key: YOUR_RUNAPI_TOKEN" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-6",
"messages": [{"role": "user", "content": "How many tokens?"}]
}'
Returns {"input_tokens": \x3Cn>}. Image blocks use a 512-token heuristic; for
exact billed counts read usage from the actual POST /v1/messages response.
List models
curl https://runapi.ai/v1/models -H "x-api-key: YOUR_RUNAPI_TOKEN"
Returns Anthropic-compatible model objects.
Supported models
| Model ID | Use when |
|---|---|
claude-opus-4-7 |
Strongest general model — agents, complex reasoning |
claude-opus-4-6 |
High-end reasoning workloads |
claude-sonnet-4-6 |
Balanced default for production chat |
claude-opus-4-5-20251101 |
Pin Opus 4.5 snapshot |
claude-sonnet-4-5-20250929 |
Pin Sonnet 4.5 snapshot (supports include_thoughts) |
claude-haiku-4-5-20251001 |
Highest throughput, lowest cost |
Aliases auto-resolve to dated snapshots: claude-opus-4-5,
claude-sonnet-4-5, claude-haiku-4-5.
Connect Claude Code itself
ANTHROPIC_BASE_URL=https://runapi.ai \
ANTHROPIC_API_KEY=YOUR_RUNAPI_TOKEN \
claude
Agent rules
- Always pass
max_tokens— the Anthropic API rejects requests without it. - Use streaming for any response longer than a few hundred tokens. Do not hold the agent on a long blocking request.
include_thoughtsonly works on the two Sonnet models listed above; do not send it on Opus or Haiku.- Pricing, rate limits, quotas — link to \x3Chttps://runapi.ai/models/claude.md>, not this skill file.
- For exact billed token counts read
usagefrom thePOST /v1/messagesresponse, not from/v1/messages/count_tokens.
Routing
- Model page: \x3Chttps://runapi.ai/models/claude.md>
- Provider page: \x3Chttps://runapi.ai/providers/anthropic.md>
- Catalog: \x3Chttps://runapi.ai/models.md>
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install runapi-claude - 安装完成后,直接呼叫该 Skill 的名称或使用
/runapi-claude触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
claude 是什么?
Call the Claude API (claude-opus, claude-sonnet, claude-haiku) through RunAPI using the official Anthropic SDK or any Anthropic-compatible client. Use when t... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 39 次。
如何安装 claude?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install runapi-claude」即可一键安装,无需额外配置。
claude 是免费的吗?
是的,claude 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
claude 支持哪些平台?
claude 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 claude?
由 RunAPI(@runapi-ai)开发并维护,当前版本 v0.2.4。