OpenAI TypeScript SDK with MagmaRouter

The Node OpenAI client takes a baseURL in its constructor. Set it to MagmaRouter and your chat.completions calls route through the gateway.
- Base URL
- https://api.magmarouter.com/v1
- API key
- Get one, starts sk-mr-
- Example model
- glm-5.3-xploded
baseURL and apiKey
TypeScript
// npm install openai import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://api.magmarouter.com/v1", apiKey: "sk-mr-...", }); const resp = await client.chat.completions.create({ model: "glm-5.3-xploded", messages: [{ role: "user", content: "Hello" }], }); console.log(resp.choices[0].message.content);
Use baseURL: "https://api.magmarouter.com/v1" and apiKey for the key, or set OPENAI_BASE_URL and OPENAI_API_KEY in the environment. Stay on chat.completions.create; the Responses API is not served.