Skip to content

OpenAI SDK

Gate exposes an OpenAI-compatible endpoint for every model it serves, including Anthropic’s Claude models. Point the OpenAI SDK’s base URL at Gate and your existing chat.completions code keeps working, with prompt-injection scanning, audit, caching, and cost tracking added on top.

The base URL ends in /v1 because the OpenAI SDK does not append it for you. Create your Gate key (sk-gw-…) under API keys in the dashboard.

Pay through Gate

Use your Gate key as the only credential. Gate routes the request to one of your enabled providers and bills your prepaid balance.

import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://gateway.constellationgate.ai/v1",
apiKey: process.env.GATE_API_KEY, // your Gate key (sk-gw-…)
});
const res = await client.chat.completions.create({
model: "anthropic/claude-opus-4-8",
messages: [{ role: "user", content: "Hello" }],
});
console.log(res.choices[0].message.content);

The Gate key and model are placeholders. Use your own key (sk-gw-…) and any Gate-catalog model, written provider/model. Browse IDs on the dashboard’s Models page or via GET /v1/models.

Use your own keys

Send your own provider key (OpenAI shown here). Gate forwards the request to the provider with your credential and bills nothing to your Gate balance. Your provider key goes in the usual apiKey/api_key slot, your Gate key goes in X-Gate-Api-Key, and X-Gate-Upstream-Url points at the provider’s base URL.

import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://gateway.constellationgate.ai/v1",
apiKey: process.env.OPENAI_API_KEY, // your OpenAI key
defaultHeaders: {
"X-Gate-Api-Key": process.env.GATE_API_KEY, // your Gate key (sk-gw-…)
"X-Gate-Upstream-Url": "https://api.openai.com",
},
});
const res = await client.chat.completions.create({
model: "gpt-4o-mini",
messages: [{ role: "user", content: "Hello" }],
});
console.log(res.choices[0].message.content);

The model here is whatever your upstream provider accepts (gpt-4o-mini is an OpenAI example), not a Gate catalog ID.

Confirm requests are flowing

Open the dashboard and run a request. It appears on the Messages page within a few seconds, with its model, cost, and security result. Search by the X-Gate-Request-Id response header to find an exact call.

  • Authentication: keys, and how each request decides who pays.
  • Plans: how model usage is billed.