Build
AI kit
Chat, agent and document Q&A templates, model choice and credit metering.
01Templates
| Template | What it does | Credits |
|---|---|---|
| Chat | Model picker, attachments, web search, reasoning, history and share links | 1 (web search +2) |
| Documents | Upload files, ask questions, answers cite the passage | 5 per upload, 1 per question |
| Agent | Plans and calls tools in a loop, including MCP servers | 3 |
02The guard every request passes
Signed in → workspace member → rate limit → credits → model → refund on failure. Any new AI endpoint does the same:
const ctx = await requireAiWorkspace(workspace);
const refund = await chargeAi(ctx, "chat");
try {
// call the model
} catch (error) {
await refund();
throw error;
}Prices and rate limits live in features/ai/config.ts.
03Models
Models run through Vercel AI Gateway with one AI_GATEWAY_API_KEY: Claude, GPT, Gemini, DeepSeek and more are listed in features/ai/config.ts, and adding one is a single entry. Set AI_MOCK=true to use deterministic fakes. To add image generation, speech or another AI feature, follow the add-ai-feature skill.