Getting Started
Making Your First Request
Last updated May 28, 2026
Send your first AI request through Cencori.
Learn how to send your first AI request through Cencori.
Prerequisites
- Cencori account and project.
- A project secret key in
CENCORI_API_KEY. - Provider access for the model you call. If you use
gpt-4o, your project needs OpenAI access through managed keys or BYOK. - Node.js 18+ installed.
- SDK installed with
npm install cencori.
Basic Chat Request
import { Cencori } from 'cencori';
const cencori = new Cencori();
async function main() {
const response = await cencori.ai.chat({
model: 'gpt-4o',
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'What is the capital of France?' }
]
});
console.log(response.content);
// "The capital of France is Paris."
console.log(response.usage);
// { promptTokens: 20, completionTokens: 10, totalTokens: 30 }
}
main();Streaming Response
const stream = cencori.ai.chatStream({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Tell me a joke' }]
});
for await (const chunk of stream) {
process.stdout.write(chunk.delta);
}Using Different Providers
Switch providers by changing the model:
// OpenAI
await cencori.ai.chat({ model: 'gpt-4o', messages: [...] });
// Anthropic
await cencori.ai.chat({ model: 'claude-sonnet-4.5', messages: [...] });
// Google
await cencori.ai.chat({ model: 'gemini-2.5-flash', messages: [...] });If switching models returns a provider configuration error, add that provider in Project > Providers or choose a model from a provider already configured for the project.
Direct cURL Check
Use this when you want to prove the Cencori key and provider setup work before debugging your app:
curl https://cencori.com/api/ai/chat \
-H "CENCORI_API_KEY: $CENCORI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Hello!"}]
}'View in Dashboard
After making requests, view them in your dashboard:
- Navigate to the Logs tab
- See full request/response details
- Check token usage and costs
- View security scan results
Next Steps
- AI Gateway - Multi-provider routing
- Streaming - Real-time responses
- Tool Calling - Let AI call functions