@repo/ai connects your app to multiple AI providers through the Vercel AI SDK and AI Gateway. It includes model routing, agent creation, prompt management, and cost tracking.
Usage
Create a chat agent with tools:packages/ai/agent/chat.ts
Gateway
The gateway routes requests to Anthropic, OpenAI, Google, and other providers through a single API:packages/ai/gateway/index.ts
Models
Pre-configured model constants and provider options:packages/ai/models/index.ts
Prompts
Shared system prompts for chat and title generation:packages/backend/convex/chat/api/title.ts
Web Search
Add Perplexity-powered web search as a tool (requiresPERPLEXITY_API_KEY):
packages/ai/tools/search.ts
Environment Variables
| Variable | Description |
|---|---|
AI_GATEWAY_API_KEY | Vercel AI Gateway API key |
AI_GATEWAY_URL | Gateway endpoint (defaults to https://ai-gateway.vercel.sh/v3) |
PERPLEXITY_API_KEY | Perplexity API key for web search (optional) |