Anthropic SDK

Anthropic TypeScript SDK with an uncensored Messages API

Connect @anthropic-ai/sdk to Abliterator's Anthropic-compatible endpoint: baseURL without /v1, typed streaming with messages.stream, and forced tool output.

Reviewed Anthropic SDKTypeScript

Quick answer

Create the client with new Anthropic({ baseURL: "https://abliterator.ai", apiKey: process.env.ABL_API_KEY }) and use an Abliterator model ID. The SDK adds /v1/messages, so the base URL has no path.

Abliterator answers the Anthropic Messages API at https://abliterator.ai/v1/messages, so the official TypeScript SDK needs only a new baseURL, key and model. These snippets were type-checked with tsc --strict and run on Node 22 with @anthropic-ai/sdk 1.14.

Install

npm install @anthropic-ai/sdk
export ABL_API_KEY="sk-abl-v1-..."

Create a key at /keys.

First message

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

const client = new Anthropic({
  baseURL: "https://abliterator.ai",
  apiKey: process.env.ABL_API_KEY,
});

const message = await client.messages.create({
  model: "kimi-k3.1-pro-abliterated",
  max_tokens: 1024,
  system: "You are a threat intelligence analyst.",
  messages: [{ role: "user", content: "Profile the typical initial-access methods of ransomware affiliates." }],
});

for (const block of message.content) {
  if (block.type === "text") console.log(block.text);
}
console.log(message.usage);

Narrowing on block.type is required in strict mode because content is a union of text, tool-use and other block types.

Streaming

client.messages.stream() returns a MessageStream. Subscribe to text for deltas, then await finalMessage() for the assembled result:

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

const client = new Anthropic({ baseURL: "https://abliterator.ai", apiKey: process.env.ABL_API_KEY });

const stream = client.messages
  .stream({
    model: "deepseek-v4.1-flash-abliterated",
    max_tokens: 1024,
    messages: [{ role: "user", content: "Explain Kerberoasting to a blue-team analyst, with the event IDs to watch." }],
  })
  .on("text", (delta) => process.stdout.write(delta));

const final = await stream.finalMessage();
console.log(`\n${final.stop_reason}, ${final.usage.output_tokens} output tokens`);

stream.abort() cancels the request. If you prefer raw events, client.messages.create({ ..., stream: true }) returns an async iterable of MessageStreamEvent.

Structured output with a forced tool

The Messages API returns structured data through tool calls. Force a single tool and read its input:

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

const client = new Anthropic({ baseURL: "https://abliterator.ai", apiKey: process.env.ABL_API_KEY });

type PhishVerdict = { verdict: "phishing" | "benign"; lure: string; indicators: string[] };

const response = await client.messages.create({
  model: "kimi-k3.1-pro-abliterated",
  max_tokens: 1024,
  // Kimi accepts a forced (named) tool only with reasoning off.
  thinking: { type: "disabled" },
  tools: [
    {
      name: "record_verdict",
      description: "Record the classification of an email for a trust-and-safety dataset.",
      input_schema: {
        type: "object",
        properties: {
          verdict: { type: "string", enum: ["phishing", "benign"] },
          lure: { type: "string" },
          indicators: { type: "array", items: { type: "string" } },
        },
        required: ["verdict", "lure", "indicators"],
      },
    },
  ],
  tool_choice: { type: "tool", name: "record_verdict" },
  messages: [
    {
      role: "user",
      content: "Classify: 'Your mailbox is 98% full. Verify your password at hxxp://mail-quota-check[.]top within 24h.'",
    },
  ],
});

const call = response.content.find((b) => b.type === "tool_use");
if (call?.type === "tool_use") {
  const result = call.input as PhishVerdict;
  console.log(result.verdict, result.indicators);
}

Validate input before trusting it (with Zod, for example); the schema guides the model but the SDK does not enforce it. For an agent loop with tool results, see the Python version in /docs/anthropic-sdk-openai-compatible-python.

Troubleshooting

  • 404 for /v1/v1/messages. Remove /v1 from baseURL. Only the OpenAI-format base URL, https://abliterator.ai/v1, ends in /v1.
  • Could not resolve authentication method. process.env.ABL_API_KEY was undefined and neither ANTHROPIC_API_KEY nor ANTHROPIC_AUTH_TOKEN is set. Load your env file before constructing the client.
  • Calls still reach Anthropic. Another module created its own client from ANTHROPIC_BASE_URL. Export ANTHROPIC_BASE_URL=https://abliterator.ai so every default client follows, or share one client instance.
  • 400 on server tools or files. Web search, code execution, the Files API and Message Batches are not available on Abliterator. Text, images, client tools and streaming are.
  • Browser use. The SDK refuses to run in a browser unless you set dangerouslyAllowBrowser: true, which would publish your key. Proxy through your own server.

Frequently asked questions

Will TypeScript reject a non-Claude model ID?

No. The SDK's Model type lists Claude IDs for autocomplete but also accepts any string, so "kimi-k3.1-pro-abliterated" type-checks without a cast.

How do I get structured JSON from the Messages API on Abliterator?

Declare one tool whose input_schema is the shape you want and force it with tool_choice: { type: "tool", name }; on kimi-k3.1-pro-abliterated, also set thinking: { type: "disabled" }. The tool_use block's input is the parsed object, as in the example on this page.

Does the SDK's streaming helper work with Abliterator's SSE stream?

Yes. Abliterator emits the standard Messages event sequence (message_start, content_block_delta, message_delta, message_stop), so messages.stream(), its text event and finalMessage() behave as they do against Anthropic.