npm install @anthropic-ai/sdkimport Anthropic from "@anthropic-ai/sdk";
const apiKey = process.env.GUARD_API_KEY;
if (!apiKey) throw new Error("GUARD_API_KEY is not set");
const client = new Anthropic({
apiKey,
baseURL: "https://api.guardrelay.ai",
});
const message = await client.messages.create({
model: "claude-sonnet-5",
max_tokens: 64,
messages: [{ role: "user", content: "Hello!" }],
});
console.log(message.content);npm install openaiimport OpenAI from "openai";
const apiKey = process.env.GUARD_API_KEY;
if (!apiKey) throw new Error("GUARD_API_KEY is not set");
const client = new OpenAI({
apiKey,
baseURL: "https://api.guardrelay.ai/v1",
});
const response = await client.chat.completions.create({
model: "k3",
messages: [{ role: "user", content: "Hello!" }],
max_tokens: 128,
});
console.log(response.choices[0].message.content);Kimi speaks both Chat Completions and the Anthropic Messages protocol, so both the openai package and @anthropic-ai/sdk fit: the only difference is the base URL, which carries no /v1 for the latter. Below is the openai variant. The base URL must carry /v1, the key is the same, and model takes one of the four ids — k3 with a 1,048,576-token window, plus k3-256k, kimi-for-coding and kimi-for-coding-highspeed with a 262,144-token window.
Reasoning depth is set by reasoning_effort, and all four models accept it: the value reaches the wire as sent, and Kimi itself documents the levels low, high and max. On kimi-for-coding and kimi-for-coding-highspeed there is also the thinking field, exactly as {"type": "enabled", "keep": "all"}; on the K3 models it is rejected. Streaming is the ordinary stream: true.
const stream = await client.chat.completions.create({
model: "k3",
messages: [{ role: "user", content: "Break this task down step by step" }],
max_tokens: 1024,
reasoning_effort: "high",
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}Composer and Grok are available through both packages. Below is the openai variant; with @anthropic-ai/sdk the same request goes to /v1/messages with a max_tokens field.
import OpenAI from "openai";
const apiKey = process.env.GUARD_API_KEY;
if (!apiKey) throw new Error("GUARD_API_KEY is not set");
const client = new OpenAI({
apiKey,
baseURL: "https://api.guardrelay.ai/v1",
});
const response = await client.chat.completions.create({
model: "composer-2.5",
messages: [{ role: "user", content: "Hi!" }],
max_tokens: 128,
});
console.log(response.choices[0].message.content);