@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, RAG pipelines, and cost tracking.
Usage
Create a chat agent with tools:packages/backend/convex/chat/streaming.ts
Gateway
The gateway routes requests to Anthropic, OpenAI, Google, and other providers through a single API:apps/app/api/chat/route.ts
Models
Pre-configured model constants and provider options:packages/backend/convex/chat/streaming.ts
Prompts
Shared system prompts for chat, title generation, and RAG:packages/backend/convex/chat/streaming.ts
RAG
Build retrieval-augmented generation pipelines with query preprocessing, retrieval, and reranking:packages/backend/convex/rag/ragAsTools.ts
Web Search
Add Perplexity-powered web search as a tool (requiresPERPLEXITY_API_KEY):
packages/backend/convex/agents/weather.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) |
COHERE_API_KEY | Cohere API key for reranking (optional) |
PERPLEXITY_API_KEY | Perplexity API key for web search (optional) |