DEVSAIO

Anthropic TypeScript SDK with a custom base URL

Call Claude from Node.js or edge runtimes with @anthropic-ai/sdk pointed at DEVSAIO, including streaming.

DEVSAIO team · 1 min read
Share on X

Install and configure

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

const anthropic = new Anthropic({
  baseURL: "https://devsaio.lol",
  apiKey: process.env.DEVSAIO_API_KEY,
});

Send a message

ts
const msg = await anthropic.messages.create({
  model: "claude-sonnet-4-6",
  max_tokens: 800,
  system: "Answer in plain English for non-technical readers.",
  messages: [{ role: "user", content: "What is two-factor authentication?" }],
});

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

Stream

ts
const stream = anthropic.messages.stream({
  model: "claude-sonnet-4-6",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Draft a friendly welcome email." }],
});
stream.on("text", (t) => process.stdout.write(t));
const final = await stream.finalMessage();
console.log("\nTokens:", final.usage);

When to use this vs the OpenAI SDK

Use the Anthropic SDK when your app only uses Claude and you want Claude-specific response details. Use the OpenAI SDK if you want one code path for every lab.

Try it with one API key

Claude, GPT, Gemini, DeepSeek, image and video models through one OpenAI- and Anthropic-compatible endpoint. Prepaid, pay only for what you use.

Keep reading