Anthropic SDK

Anthropic SDK

The official Anthropic SDKs work unchanged against our Messages endpoint. Set the base URL to https://api.abliteratedllm.dev, without /v1: the SDKs add /v1/messages themselves. The SDKs send your key in the x-api-key header, which we accept.

Placeholders: $API_BASE is https://api.abliteratedllm.dev/v1, $API_ORIGIN is https://api.abliteratedllm.dev, and $YOUR_KEY is your API key.

Both SDKs also read the ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY environment variables:

export ANTHROPIC_BASE_URL="$API_ORIGIN"
export ANTHROPIC_API_KEY="$YOUR_KEY"

Python

pip install anthropic
import anthropic

client = anthropic.Anthropic(base_url="$API_ORIGIN", api_key="$YOUR_KEY")

message = client.messages.create(
    model="glm-5.3-flash-abliterated",
    max_tokens=1024,
    system="You are a hard-boiled detective.",
    messages=[{"role": "user", "content": "Introduce yourself in three sentences."}],
)
print(message.content[0].text)
print(message.usage)

Streaming, with thinking enabled:

with client.messages.stream(
    model="glm-5.3-flash-abliterated",
    max_tokens=8192,
    thinking={"type": "enabled", "budget_tokens": 4096},
    messages=[{"role": "user", "content": "Plot a three-act heist story."}],
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)
    print("\n", stream.get_final_message().usage)

TypeScript and JavaScript

npm install @anthropic-ai/sdk
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({ baseURL: "$API_ORIGIN", apiKey: "$YOUR_KEY" });

const message = await client.messages.create({
  model: "glm-5.3-flash-abliterated",
  max_tokens: 1024,
  system: "You are a hard-boiled detective.",
  messages: [{ role: "user", content: "Introduce yourself in three sentences." }],
});
console.log(message.content);
console.log(message.usage);

Streaming:

const stream = client.messages.stream({
  model: "glm-5.3-flash-abliterated",
  max_tokens: 2048,
  messages: [{ role: "user", content: "Plot a three-act heist story." }],
});
stream.on("text", (text) => process.stdout.write(text));
const final = await stream.finalMessage();
console.log("\n", final.usage);

Good to know

  • max_tokens is required, as in the Anthropic API. Trial accounts are capped at 4096.
  • Thinking budgets of 1024 to 4999 tokens run at low effort, 5000 to 9999 at medium, and 10000 or more at high. budget_tokens must be lower than max_tokens. See POST /v1/messages.
  • Usage. input_tokens excludes cache reads, which are reported in cache_read_input_tokens and billed at the cached-input price.
  • Errors use the Anthropic shape, so the SDKs raise their usual exceptions. Statuses and codes are on the Errors page.
  • Not available: token counting (messages.count_tokens), message batches, and Anthropic's server-side tools.
  • Text only. Image blocks fail with 400 unsupported_content.

Verified against Anthropic SDK docs on 2026-11-03: anthropic-sdk-python (base_url, ANTHROPIC_BASE_URL) and anthropic-sdk-typescript (baseURL, ANTHROPIC_BASE_URL).