Skip to main content
Route your OpenAI requests through the Inference Catalyst gateway to get cost tracking, latency monitoring, and analytics. You keep your existing OpenAI API key — just point the SDK at the gateway and add a few headers.
Prefer automatic setup? Run inf instrument to instrument your codebase in seconds. Learn more

Setup

1

Get your API keys

You need two keys:
  • Inference Catalyst project API key — from your dashboard under API Keys
  • OpenAI API key — from your OpenAI account
2

Set environment variables

export INFERENCE_API_KEY=<your-project-api-key>
export OPENAI_API_KEY=<your-openai-api-key>
3

Update your code

Point the SDK at the gateway. Your project API key goes in apiKey to authenticate with the gateway, and your OpenAI key goes in x-inference-provider-api-key so the gateway can forward it to OpenAI.
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.OPENAI_API_KEY,
    "x-inference-provider": "openai",
    "x-inference-environment": process.env.NODE_ENV,
  },
});

const response = await client.chat.completions.create({
  model: "gpt-4.1",
  messages: [{ role: "user", content: "Hello" }],
}, {
  headers: { "x-inference-task-id": "default" },
});