Claude Agent SDK (TypeScript) on MagmaRouter

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.
- Base URL
- https://api.magmarouter.com
- API key
- Get one, starts sk-mr-
- Example model
- glm-5.3-xploded
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:
TypeScript
// 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://api.magmarouter.com", ANTHROPIC_AUTH_TOKEN: process.env.MAGMAROUTER_API_KEY, ANTHROPIC_MODEL: "glm-5.3-xploded", }, }, })) { console.log(message); }
Set MAGMAROUTER_API_KEY in your own environment to a key from /chat. Every caveat from the Claude Code guide applies, including the tool-calling requirement.