AI
AI Gateway
Last updated April 17, 2026
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
| Endpoint | Description | Providers |
|---|---|---|
/api/ai/chat | Chat completions | OpenAI, Anthropic, Google, xAI, Mistral, DeepSeek, Meta |
/api/ai/embeddings | Vector embeddings | OpenAI, Google, Cohere |
/api/ai/images/generate | Image generation | OpenAI, Google |
/api/ai/audio/transcriptions | Speech-to-text | OpenAI |
/api/ai/audio/speech | Text-to-speech | OpenAI |
/api/ai/moderation | Content moderation | OpenAI |
https://api.cencori.com/v1/chat/completions | OpenAI-compatible chat endpoint | OpenAI-compatible clients |
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_... - Required for
https://api.cencori.com/v1/*:Authorization: Bearer csk_...
Create and manage project keys in the dashboard.