Skip to main content

AI API in apps

Kazzle apps should use Kazzle’s AI API for chat, images, speech, transcription, and video. Do not ask users for OpenAI, Anthropic, or other provider keys unless they specifically want to bill those providers directly.

What to use

All app AI calls go through https://api.kazzle.app plus a kzl_ API key:
const apiUrl = 'https://api.kazzle.app';
const apiKey = process.env.KAZZLE_API_KEY;

if (!apiKey) {
  throw new Error('KAZZLE_API_KEY is required');
}

const response = await fetch(`${apiUrl}/ai/audio/transcriptions`, {
  method: 'POST',
  headers: { Authorization: `Bearer ${apiKey}` },
  body: formData,
});
KAZZLE_API_KEY is an app credential you create with the api_key tool, store in the vault, and wire into the app’s process component.

Common endpoints

JobEndpoint
Chat or text generationPOST /ai/chat/completions
ImagesPOST /ai/images/generations
Text to speechPOST /ai/audio/speech
Speech to textPOST /ai/audio/transcriptions
Video generationPOST /ai/video/generations
Model catalogGET /ai/models
Read /ai/models first when the app needs to pick a model dynamically.

Wiring the API key

  1. Create a scoped Kazzle API key for the app.
  2. Store it in a secret collection + environment with the name KAZZLE_API_KEY (the secret name becomes the env var key).
  3. Point the process component at that collection + environment.
  4. Keep calls server-side unless the endpoint is intentionally public through your own backend.
export default defineConfig({
  components: [
    {
      name: 'server',
      type: 'process',
      path: './server',
      env: {
        collection: 'my-app',
        environment: 'default'
      }
    }
  ]
});
The server process will see process.env.KAZZLE_API_KEY resolved from the vault at runtime. There is no env.vars field — secrets only reach app components through the collection + environment they point at. Never put a private API key in frontend code or a VITE_* variable.