claudelisted
Install: claude install-skill runapi-ai/claude
# Claude on RunAPI
Use Anthropic Messages at `https://runapi.ai` with `POST /v1/messages` as the primary protocol.
## Primary protocol recipe
### Authenticate
Set `ANTHROPIC_API_KEY` to a RunAPI API key and `ANTHROPIC_BASE_URL` to
`https://runapi.ai`. The SDK sends `x-api-key`; Bearer authentication is also accepted.
### Send request
```python
import anthropic
client = anthropic.Anthropic(api_key="YOUR_RUNAPI_TOKEN", base_url="https://runapi.ai")
message = client.messages.create(
model="claude-sonnet-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Explain this decision."}],
)
print(message.content[0].text)
print(message.usage)
```
`max_tokens` is required. For long output, use `client.messages.stream(...)`
and consume `stream.text_stream` through the terminal event. Add image blocks,
function tools, reasoning controls, or token counting only when the current
RunAPI contract verifies them for the selected exact model.
### Verify result
Require final text, `stop_reason`, and authoritative `usage`. A stream is
complete only after terminal Usage and `message_stop`. Token counting estimates
input only; actual response Usage remains authoritative.
### Stop boundaries
Correct a rejected shape once using the structured error. Retry transport once
only before any response or Usage and when replay is safe. Record a terminal
error and stop without changing model or protocol.
## Compatibility protocols
Load [compatibility protocols](references/compati