DocsSDKs and frameworks
Anthropic SDK
Use the Anthropic SDKs for Python and TypeScript with your Osarai instance through its Messages API.
The Anthropic SDKs call Osarai's Messages API. Give them the site address https://osarai.xyz (they add /v1/messages) and your qck_… key. The model is the open model on your instance.
Install
Terminal
pip install anthropicTerminal
npm install @anthropic-ai/sdkConfigure
Both SDKs read these environment variables:
Terminal
export ANTHROPIC_BASE_URL="https://osarai.xyz"
export ANTHROPIC_API_KEY="$OSARAI_API_KEY"Or pass them explicitly:
Python
import anthropic, os
client = anthropic.Anthropic(base_url="https://osarai.xyz", api_key=os.environ["OSARAI_API_KEY"])TypeScript
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({ baseURL: "https://osarai.xyz", apiKey: process.env.OSARAI_API_KEY });Messages
Python
message = client.messages.create(
model="qwen3.8-27b",
max_tokens=1024,
messages=[{"role": "user", "content": "Explain recursion in one paragraph."}],
)
for block in message.content:
if block.type == "text":
print(block.text)TypeScript
const message = await client.messages.create({
model: "qwen3.8-27b",
max_tokens: 1024,
messages: [{ role: "user", content: "Explain recursion in one paragraph." }],
});
for (const block of message.content) if (block.type === "text") console.log(block.text);Reasoning models answer with a thinking block before the text block, so read blocks by type rather than taking content[0].
Streaming
Python
with client.messages.stream(
model="qwen3.8-27b",
max_tokens=1024,
messages=[{"role": "user", "content": "Write a limerick about GPUs."}],
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)TypeScript
const stream = client.messages.stream({
model: "qwen3.8-27b",
max_tokens: 1024,
messages: [{ role: "user", content: "Write a limerick about GPUs." }],
});
stream.on("text", (text) => process.stdout.write(text));
await stream.finalMessage();Thinking
Python
message = client.messages.create(
model="qwen3.8-27b",
max_tokens=4096,
thinking={"type": "enabled", "budget_tokens": 2000}, # low effort
messages=[{"role": "user", "content": "Is 221 prime?"}],
)Use {"type": "disabled"} for the fastest answers. See Thinking for how budgets map to effort.
What differs from Anthropic's API
- Anthropic's server tools (web search, code execution), prompt caching and the Files API are not available; requests that include them still work, without those parts.
count_tokenscounts with your model's tokenizer, not Claude's.- Model names are your instance's ids, such as
qwen3.8-27b.