Skip to content

Custom backends

Use a custom backend when you need full control over routing, tools, memory, or security. Provide a custom fetch function to use for API requests and orchestrate model calls yourself.

  • Use the ChatKit Python SDK for fast integration
  • Or integrate directly with your model provider and implement compatible events
const auth = getUserAuth(); // your custom auth info
const { control } = useChatKit({
api: {
url: 'https://your-domain.com/your/chatkit/api',
// Any info you inject in the custom fetch callback is invisible to ChatKit.
fetch(url: string, options: RequestInit) {
return fetch(url, {
...options,
// Inject your auth header here.
headers: {
...options.headers,
"Authorization": `Bearer ${auth}`,
},
// You can override any options here
});
},
// Required when attachments are enabled.
uploadStrategy: {
type: "direct",
uploadUrl: "https://your-domain.com/your/chatkit/api/upload",
}
// Register your domain in the dashboard at
// https://platform.openai.com/settings/organization/security/domain-allowlist
domainKey: "your-domain-key",
},
});