Claude Agent SDK (TypeScript) on Redline

The TypeScript Claude Agent SDK starts the Claude Code binary under the hood, so it takes the same environment variables. There is no base-URL option on the SDK itself; you pass the environment through the query options.

Pass the environment through options.env

The SDK has no gateway-specific option. Its options.env replaces the child process environment, so spread process.env and add the Anthropic variables:

// npm install @anthropic-ai/claude-agent-sdk
import { query } from "@anthropic-ai/claude-agent-sdk";

for await (const message of query({
  prompt: "List the files in this repo",
  options: {
    env: {
      ...process.env,
      ANTHROPIC_BASE_URL: "https://redline-gateway.pages.dev",
      ANTHROPIC_AUTH_TOKEN: process.env.REDLINE_API_KEY,
      ANTHROPIC_MODEL: "deepseek/deepseek-chat-v3.1",
    },
  },
})) {
  console.log(message);
}

Set REDLINE_API_KEY in your own environment to a key from /app. Every caveat from the Claude Code guide applies, including the tool-calling requirement.

Related guides