AI Gateway
The secure, unified API layer for your AI requests across models, providers, and runtime policies.
The AI Gateway is Cencori's runtime control point. Your application sends AI traffic to Cencori once, and Cencori handles provider routing, security enforcement, observability, and cost tracking.
Available Endpoints
Use https://api.cencori.com/v1 as the base URL for OpenAI-compatible SDKs. Most SDKs append /chat/completions automatically.
SDK Usage
import { Cencori } from 'cencori';
const cencori = new Cencori({
apiKey: process.env.CENCORI_API_KEY,
});
const response = await cencori.ai.chat({
model: 'gpt-4o',
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'Hello!' },
],
temperature: 0.7,
maxTokens: 1000,
});
console.log(response.content);
console.log(response.usage); // { promptTokens, completionTokens, totalTokens }Streaming
const stream = cencori.ai.chatStream({
model: 'claude-opus-4',
messages: [{ role: 'user', content: 'Tell me a story' }],
});
for await (const chunk of stream) {
process.stdout.write(chunk.delta);
}Tool Calling
const response = await cencori.ai.chat({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'What is the weather in Tokyo?' }],
tools: [
{
type: 'function',
function: {
name: 'get_weather',
description: 'Get weather for a location',
parameters: {
type: 'object',
properties: { location: { type: 'string' } },
required: ['location'],
},
},
},
],
});
console.log(response.toolCalls);Direct API Usage
Native Cencori Endpoint
curl -X POST https://cencori.com/api/ai/chat \
-H "CENCORI_API_KEY: csk_..." \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Hello!"}],
"stream": false
}'OpenAI-Compatible Endpoint
curl -X POST https://api.cencori.com/v1/chat/completions \
-H "Authorization: Bearer csk_..." \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Hello!"}]
}'Authentication
Every request requires a project API key:
- Preferred for
/api/ai/*:CENCORI_API_KEY: csk_... - Preferred for
https://api.cencori.com/v1/*:Authorization: Bearer csk_...
Create and manage project keys in the dashboard. If authentication succeeds but routing fails with a provider configuration error, add your provider key in AI Gateway → BYOK or choose a model from an enabled provider.
PII protection (opt-in, off by default)
The gateway's only built-in request check is PII protection. It applies the same way to managed keys and BYOK, streaming and non-streaming, native and OpenAI-compatible endpoints.
- Default: off. Requests pass through unchanged and return
200 OK, even if they contain personal data. This is expected, not a bypass. - To turn it on: open the project's Settings → General, and under Request handling turn on PII protection (paid plans).
- When on: any email address, phone number, US SSN, or card number in the input blocks the request with
403 security_violation. Nothing is masked — the request is either blocked or passed through unchanged. Model responses are not scanned. - Bypass:
passthrough: true/fast_lane: truebody fields, orx-cencori-passthrough: true/x-cencori-fast-lane: trueheaders, skip the check on chat requests.
If you test with an email or card number and get 200 OK, check whether PII protection is on for the project before assuming a provider-key (BYOK) issue.

