子与 NordRouter
支持标准的fetch,因此不需要额外的HTTP-包.
ts
const response = await fetch("https://nordrouter.com/v1/chat/completions", {
method: "POST",
headers: {
Authorization: `Bearer ${Bun.env.NORDROUTER_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "anthropic/claude-sonnet-4.6",
messages: [{ role: "user", content: "Ответь: работает" }],
}),
});
if (!response.ok) throw new Error(await response.text());
const data = await response.json();
console.log(data.choices[0].message.content);启动:bun run index.ts.把钥匙放在变量环境中.