Calling Stratix from a backend
Calling Stratix from a backend — TS, Go, Python patterns. Keep keys server-side; never in browsers.
The pattern
[Browser] → [Your backend] → [Stratix API]
key in env X-API-Key headerNext.js (TypeScript)
import { NextRequest, NextResponse } from "next/server";
export async function POST(req: NextRequest) {
const body = await req.json();
const stratix = await fetch("https://stratix.layerlens.ai/api/v1/evaluations", {
method: "POST",
headers: {
"X-API-Key": process.env.LAYERLENS_STRATIX_API_KEY!,
"Content-Type": "application/json",
},
body: JSON.stringify({
model_id: body.model_id,
benchmark_id: body.benchmark_id,
}),
});
return NextResponse.json(await stratix.json(), { status: stratix.status });
}Express (Node)
Go (net/http)
Python (FastAPI)
Why not call Stratix directly from the browser?
Per-user authorization
Streaming responses to the browser
CORS guidance
See also
Last updated
Was this helpful?