Forge is available: build a website with AI from your RodiumAi account.

Try Forge
RodiumAi docs
Guides

Anthropic Messages SDK

Drop-in for the Anthropic Python/TS packages: same Messages shape, Rodium key, Claude models.

POSThttps://api.rodiumai.io/v1/messages

Prefer this path when your app already uses the Anthropic SDK. OpenAI-compatible chat still works for Claude via /v1/chat/completions.

Anthropic SDK vs OpenAI SDK

OpenAI clients use base_url https://api.rodiumai.io/v1 and chat.completions. Anthropic clients use base_url https://api.rodiumai.io (no /v1) and messages.create. Same rd_sk_… secret; never send Anthropic’s server key to clients.

Install

…

First message

…

Streaming (native Anthropic SSE)

…

Request parameters

ParameterTypeRequiredDescription
modelstringRequiredClaude catalogue id (e.g. anthropic/claude-sonnet-4-6). Only anthropic/* models are served on this endpoint. POST /v1/messages/count_tokens takes the same body and returns input_tokens for free.
messagesarrayRequiredAnthropic Messages array (role + content blocks or text).
max_tokensintegerRequiredMaximum output tokens (required by Anthropic Messages).
systemstring | arrayOptionalOptional system prompt.
streambooleanOptionalWhen true, returns native Anthropic SSE (message_start, content_block_delta, …).
temperaturenumberOptionalSampling temperature when supported.
toolsarrayOptionalAnthropic tool definitions; tool_use / tool_result blocks round-trip unchanged.

API reference: POST /v1/messages

Scope of /v1/messages

  • Only Claude models (anthropic/*) are served here; RodiumAI may route them through Anthropic, Amazon Bedrock or Azure without changing the response shape. Other models are not available on this endpoint: call them with /v1/chat/completions.
  • On routes without a native Messages API (Amazon Bedrock), the gateway translates the request: client tools, tool_use / tool_result turns and images are kept. Provider-hosted tools (web search, code execution) only run on native Anthropic routes; elsewhere they are skipped.
  • Smart aliases (rodiumai/smart, rodium/*) and custom models are chat-completions only.
  • Authenticate with x-api-key (what the Anthropic SDK sends) or Authorization: Bearer. anthropic-version is optional.
  • Set max_tokens: it is required by the Messages format and bounds the cost. speed values other than standard are not forwarded, so requests run at standard speed and price.
  • Searches made by Anthropic's hosted web search tool (usage.server_tool_use.web_search_requests) are billed per call on top of tokens, see Pricing.

POST /v1/messages/count_tokens

Anthropic-compatible token counting, so clients such as Claude Code can size their context window. Send the same body as /v1/messages (model is required; max_tokens is not); the answer is {"input_tokens": N}. Same authentication as /v1/messages (x-api-key or Authorization: Bearer). The call is free: nothing is reserved or billed.

…

input_tokens is the gateway's own estimate (the one used to size pre-flight holds), not the provider's tokenizer: use it to size prompts, not to predict the bill exactly. Errors use the Anthropic format; an invalid key returns 401 authentication_error.

Errors

Body validation and streaming errors use Anthropic's {"type": "error", "error": {…}} format; errors raised before the call (authentication, balance, quota, rate limit) use the OpenAI-style envelope. Details: API errors.