Integrations
Anthropic SDK
Use the Anthropic SDKs with Sovereign by changing the base URL and the key.
Set it up
import anthropic
client = anthropic.Anthropic(base_url="https://sov.solibra.ai", api_key="sov_live_…")
message = client.messages.create(
model="claude-sonnet-5-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Write a haiku about invoices."}],
)
print(message.content[0].text)
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({ baseURL: "https://sov.solibra.ai", apiKey: "sov_live_…" });
const message = await client.messages.create({
model: "claude-sonnet-5-5",
max_tokens: 1024,
messages: [{ role: "user", content: "Write a haiku about invoices." }],
});
console.log(message.content[0].text);
The SDK's ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY environment variables work too.
Streaming
with client.messages.stream(
model="claude-sonnet-5-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Explain prompt caching in one paragraph."}],
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)
const stream = client.messages.stream({
model: "claude-sonnet-5-5",
max_tokens: 1024,
messages: [{ role: "user", content: "Explain prompt caching in one paragraph." }],
});
for await (const event of stream) {
if (event.type === "content_block_delta" && event.delta.type === "text_delta") process.stdout.write(event.delta.text);
}
Tools, images and caching
- Tools work as in the Messages API. Requests with tools only go to models that support tool use.
- Images only go to models that accept them.
- Prompt caching: your
cache_controlmarkers are kept. If you set none, Sovereign turns on caching for Claude models. See Prompt caching.
Counting tokens
client.messages.count_tokens(...) works and returns an estimate. See Count tokens.