Gateway
OpenRouter
Route OpenRouter requests through Inference for full observability.
Route your OpenRouter requests through the Inference gateway to access hundreds of models while getting full observability. OpenRouter is OpenAI-compatible, so you use the OpenAI SDK with the x-inference-provider-url header.
inf instrument to instrument your codebase in seconds. Learn moreInference also exposes an OpenRouter-compatible model listing at https://api.inference.net/openrouter/v1/models. It is public (no auth) and mirrors the shared model catalog. A model's fast tier is listed as its own model id (e.g. moonshotai/kimi-k3-fast) under the same OpenRouter slug, priced at the fast tier's rates.
Setup
Get your API keys
You need two keys:
- Inference project API key — from your dashboard under API Keys
- OpenRouter API key — from your OpenRouter account
Set environment variables
export INFERENCE_API_KEY=<your-project-api-key>
export OPENROUTER_API_KEY=<your-openrouter-api-key>Update your code
Point the SDK at the gateway. Your project API key goes in apiKey, and the x-inference-provider-url header tells the gateway to forward requests to OpenRouter.
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.inference.net/v1",
apiKey: process.env.INFERENCE_API_KEY,
defaultHeaders: {
"x-inference-provider-api-key": process.env.OPENROUTER_API_KEY,
"x-inference-provider-url": "https://openrouter.ai/api/v1",
"x-inference-environment": process.env.NODE_ENV,
},
});
const response = await client.chat.completions.create({
model: "z-ai/glm-5-turbo",
messages: [{ role: "user", content: "Hello" }],
}, {
headers: { "x-inference-task-id": "default" },
});