Call Claude from your code with the Anthropic or OpenAI SDK
Any program that uses the Anthropic SDK can call Claude through your key: change the base URL and the API key. Programs written for the OpenAI format work too, with one limitation.
The RoamAI teamPublished October 16, 2026
Python
Install the SDK with pip install anthropic, then:
from anthropic import Anthropic
client = Anthropic(
base_url="https://relay.roamai.cloud:18443",
api_key="rak1_YOUR_KEY",
)
message = client.messages.create(
model="claude-sonnet-5-5",
max_tokens=4096,
messages=[{"role": "user", "content": "Explain idempotency in one sentence."}],
)
print("".join(b.text for b in message.content if b.type == "text"))You can leave the address and key out of the code: set ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY, and Anthropic() with no arguments reads them.
TypeScript
Install the SDK with npm install @anthropic-ai/sdk, then:
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
baseURL: "https://relay.roamai.cloud:18443",
apiKey: "rak1_YOUR_KEY",
});
const message = await client.messages.create({
model: "claude-sonnet-5-5",
max_tokens: 4096,
messages: [{ role: "user", content: "Explain idempotency in one sentence." }],
});
for (const block of message.content) {
if (block.type === "text") console.log(block.text);
}Streaming
For long answers or a large max_tokens, stream the response so the request does not time out:
with client.messages.stream(
model="claude-sonnet-5-5",
max_tokens=16000,
messages=[{"role": "user", "content": "Write a 200-word release note."}],
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)Reasoning effort
Set the effort in output_config: low, medium, high, xhigh or max. If the key has an effort cap, a higher setting runs at the cap and the request still completes.
message = client.messages.create(
model="claude-opus-5-5",
max_tokens=8192,
output_config={"effort": "low"},
messages=[{"role": "user", "content": "Rename these variables to snake_case: ..."}],
)Web search
Add the web search tool and the model searches when it needs to:
message = client.messages.create(
model="claude-sonnet-5-5",
max_tokens=4096,
tools=[{"type": "web_search_20260209", "name": "web_search", "max_uses": 3}],
messages=[{"role": "user", "content": "What is the latest Node.js LTS release?"}],
)Searches are charged per search. Other server tools, such as web fetch and code execution, are not supported and are ignored if you include them.
The OpenAI format
For programs that only speak the OpenAI Chat Completions format, add /v1 to the base URL:
from openai import OpenAI
client = OpenAI(
base_url="https://relay.roamai.cloud:18443/v1",
api_key="rak1_YOUR_KEY",
)
resp = client.chat.completions.create(
model="claude-sonnet-5-5",
messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)This format supports streaming (stream=True) and reasoning_effort. It does not support tool calls; use the Anthropic format for tools.
Model names
Use a model id from /v1/models. To see the list:
curl https://relay.roamai.cloud:18443/v1/models \
-H "x-api-key: rak1_YOUR_KEY" \
-H "anthropic-version: 2023-06-01"The ids in the list can go into model exactly as shown.
One key per person for Claude Code
RoamAI is a Claude API for teams: issue a key in the console and put it into Claude Code, Claude Desktop or an SDK. No monthly fee; usage is charged per token.
Get started