NordRouter in Vercel Edge Functions
In Vercel, add the secret NORDROUTER_API_KEY to Project Settings → Environment Variables.
ts
import OpenAI from "openai";
export const runtime = "edge";
const client = new OpenAI({
apiKey: process.env.NORDROUTER_API_KEY,
baseURL: "https://nordrouter.com/v1",
});
export async function POST(request: Request) {
const { prompt } = await request.json();
const result = await client.chat.completions.create({
model: "anthropic/claude-sonnet-4.6",
messages: [{ role: "user", content: prompt }],
});
return Response.json({ text: result.choices[0].message.content });
}Add the secret separately for the required Development, Preview and Production environments. Do not pass it in variables with the NEXT_PUBLIC_ prefix.