Integrations
Supabase
Last updated April 17, 2026
Build a full-stack AI app with Supabase (Auth + DB) and Cencori (intelligence and AI runtime controls).
Supabase provides the database and authentication. Cencori provides the AI routing, memory, and runtime controls. Together, they give you a strong server-side foundation for production AI apps.
Why Use Them Together?
- Unified Auth: propagate Supabase user identity into Cencori requests.
- Vector Workflows: sync app data into Cencori memory for retrieval and RAG.
- Edge-Friendly Execution: call Cencori from Supabase Edge Functions.
1. Setup
# .env.local
NEXT_PUBLIC_SUPABASE_URL=your-project-url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
CENCORI_API_KEY=csk_live_...2. Edge Functions (Deno)
// supabase/functions/chat/index.ts
import { serve } from 'https://deno.land/std@0.168.0/http/server.ts';
serve(async (req) => {
const authHeader = req.headers.get('Authorization');
if (!authHeader) {
return new Response('Unauthorized', { status: 401 });
}
const messages = await req.json();
const response = await fetch('https://api.cencori.com/v1/chat/completions', {
method: 'POST',
headers: {
Authorization: `Bearer ${Deno.env.get('CENCORI_API_KEY')}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'gpt-4o',
messages,
stream: true,
}),
});
return new Response(response.body, {
headers: { 'Content-Type': 'text/event-stream' },
});
});3. Database Triggers (Vector Workflows)
For inserts and updates, trigger your own Edge Function and let that function call Cencori with server-side credentials.
create trigger on_document_created
after insert on public.documents
for each row execute function
supabase_functions.http_request(
'https://YOUR_PROJECT.functions.supabase.co/sync-memory',
'POST',
'{"Content-Type":"application/json"}',
json_build_object(
'content', new.content,
'metadata', json_build_object('id', new.id)
)::text
);Then, inside sync-memory, use the Cencori SDK or your own backend route to store or index the document in a project memory namespace.
4. Auth And User Identity
When you want per-user attribution, pass the Supabase user ID into the chat request.
const { data: { user } } = await supabase.auth.getUser();
await fetch('https://cencori.com/api/ai/chat', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'CENCORI_API_KEY': process.env.CENCORI_API_KEY!,
},
body: JSON.stringify({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Summarize my dashboard activity.' }],
userId: user?.id,
}),
});