Anthropic TypeScript SDK with Redline

The TypeScript Anthropic SDK mirrors the Python one: a configurable baseURL and an authToken that goes out as a bearer header.

baseURL and authToken

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

const client = new Anthropic({
  baseURL: "https://redline-gateway.pages.dev",
  authToken: "rl-...",
});

const msg = await client.messages.create({
  model: "deepseek/deepseek-chat-v3.1",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Hello" }],
});
console.log(msg.content[0].text);

Use baseURL: "https://redline-gateway.pages.dev" (no /v1) and authToken for the key. The SDK can also read ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN from the environment if you prefer not to pass them in code.

Related guides