cencori
v1.2.1
Published
Cencori - The unified infrastructure layer for AI applications. One SDK for AI Gateway, Compute, Workflow, and Storage.
Maintainers
Readme
Cencori
The unified infrastructure layer for AI applications.
One SDK. Every AI primitive. Always secure. Always logged.
npm install cencoriQuick Start
import { Cencori } from 'cencori';
const cencori = new Cencori({
apiKey: process.env.CENCORI_API_KEY
});
// AI Gateway - Chat with any model
const response = await cencori.ai.chat({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Hello!' }]
});
console.log(response.content);Products
| Product | Status | Description | |---------|--------|-------------| | AI Gateway | ✅ Available | Multi-provider routing, security, observability | | Billing | ✅ Available | End-user usage monetization and Stripe integration | | Integration | ✅ Available | SDKs, Vercel AI, TanStack |
AI Gateway
Chat Completions
const response = await cencori.ai.chat({
model: 'gpt-4o', // or 'claude-3-opus', 'gemini-1.5-pro', etc.
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'What is the capital of France?' }
],
temperature: 0.7,
maxTokens: 1000
});
console.log(response.content);
console.log(response.usage); // { promptTokens, completionTokens, totalTokens }Multimodal (Image Input)
const response = await cencori.ai.chat({
model: 'gpt-4o',
messages: [{
role: 'user',
content: [
{ type: 'text', text: 'What is in this image?' },
{ type: 'image_url', image_url: { url: 'https://example.com/image.jpg' } }
]
}]
});Tool Usage (Function 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 the current weather for a location',
parameters: {
type: 'object',
properties: { location: { type: 'string' } },
required: ['location']
}
}
}]
});
if (response.toolCalls) {
console.log(response.toolCalls); // [{ function: { name: 'get_weather', arguments: '{"location":"Tokyo"}' } }]
}Structured Output (Object Generation)
interface UserProfile {
name: string;
age: number;
interests: string[];
}
const response = await cencori.ai.generateObject<UserProfile>({
model: 'gpt-4o',
prompt: 'Generate a fictional user profile',
schema: {
type: 'object',
properties: {
name: { type: 'string' },
age: { type: 'number' },
interests: { type: 'array', items: { type: 'string' } }
},
required: ['name', 'age', 'interests']
}
});
console.log(response.object); // { name: 'Alice', age: 28, interests: ['hiking'] }Embeddings
const response = await cencori.ai.embeddings({
model: 'text-embedding-3-small',
input: 'Hello world'
});
console.log(response.embeddings[0]); // [0.1, 0.2, ...]Image Generation
Generate images from text prompts using multiple providers:
const response = await cencori.ai.generateImage({
prompt: 'A futuristic city at sunset with flying cars',
model: 'gpt-image-1.5', // Best text rendering, top ELO rating
size: '1024x1024',
quality: 'hd'
});
console.log(response.images[0].url); // https://...Supported Models:
| Provider | Models | Description |
|----------|--------|-------------|
| OpenAI | gpt-image-1.5, gpt-image-1, dall-e-3, dall-e-2 | Text rendering, creative |
| Google | gemini-3-pro-image, imagen-3 | High photorealism |
Framework Integrations
Vercel AI SDK
import { cencori } from 'cencori/vercel';
import { streamText } from 'ai';
const result = await streamText({
model: cencori('gpt-4o'),
messages: [{ role: 'user', content: 'Hello!' }]
});
for await (const chunk of result.textStream) {
console.log(chunk);
}With React/Next.js
import { cencori } from 'cencori/vercel';
import { useChat } from '@ai-sdk/react';
export default function Chat() {
const { messages, input, handleInputChange, handleSubmit } = useChat({
api: '/api/chat'
});
return (
<div>
{messages.map(m => <div key={m.id}>{m.content}</div>)}
<form onSubmit={handleSubmit}>
<input value={input} onChange={handleInputChange} />
</form>
</div>
);
}Why Cencori?
- 🛡️ Security Built-in: PII detection, content filtering, jailbreak protection
- 📊 Observability: Every request logged, every token tracked
- 💰 Cost Control: Budget alerts, spend caps, per-request costing
- 🔄 Multi-Provider: Switch between OpenAI, Anthropic, Google, etc.
- ⚡ One SDK: AI model routing, security shield, and billing - unified
Links
License
MIT
