For initial setup, see the Quickstart which covers the one-click deploy flow.
Vercel Integrations
ChatJS uses several Vercel platform features. Enable them in your Vercel dashboard under Storage and AI.| Integration | Purpose | Required |
|---|---|---|
| Vercel Postgres or Neon | Primary database | Yes |
| Vercel Blob | File attachments, generated images | If using attachments/image gen |
| Vercel KV | Resumable streams (Redis) | Optional |
| AI Gateway | Unified access to 120+ AI models | Yes |
AI Gateway
AI Gateway provides a single API key to access models from OpenAI, Anthropic, Google, and more.- Go to Vercel AI Gateway
- Create an API key
- Add to environment:
AI_GATEWAY_API_KEY
Blob Storage
Required for file attachments and AI image generation.- Go to Storage → Create → Blob
- Connect to your project
- Environment variable
BLOB_READ_WRITE_TOKENis auto-added
chat.config.ts:
KV (Redis)
Enables resumable streams - users can refresh the page mid-generation and continue where they left off.- Go to Storage → Create → KV
- Connect to your project
- Environment variable
REDIS_URLis auto-added
Cron Jobs
ChatJS includes a daily cleanup job that removes orphaned blob attachments (uploaded but never saved to a message).Configuration
Defined invercel.json:
Security
The cron endpoint requires aCRON_SECRET environment variable:
Customizing Cleanup
Editapp/api/cron/cleanup/route.ts to add cleanup tasks:
Code Execution Sandbox
The code execution tool uses Vercel Sandbox for secure Python execution.Authentication
On Vercel, sandbox uses OIDC automatically. For local development or self-hosted:Runtime Configuration
Set the Python version via environment variable:Resource Limits
Sandboxes run with:- 2 vCPUs
- 5 minute timeout
- Pre-installed: matplotlib, pandas, numpy, sympy, yfinance
Environment Variables
Required
| Variable | Description |
|---|---|
DATABASE_URL | PostgreSQL connection string |
AUTH_SECRET | Session encryption key |
AI_GATEWAY_API_KEY | Vercel AI Gateway key |
Optional (Vercel Features)
| Variable | Feature |
|---|---|
BLOB_READ_WRITE_TOKEN | Blob storage (auto-set by integration) |
REDIS_URL | KV/Redis for resumable streams |
CRON_SECRET | Secure cron endpoint |
Pull from Vercel
After linking your project, pull all environment variables:Production Checklist
Before going live:Enable production domain
Enable production domain
- Go to Settings → Domains
- Add your custom domain
- Update OAuth callback URLs to use the new domain
Configure OAuth for production
Configure OAuth for production
Update your OAuth apps (GitHub, Google) with production callback URLs:
Set up monitoring
Set up monitoring
- Enable Vercel Analytics for web vitals
- Configure Langfuse for LLM observability (optional)
Review storage limits
Review storage limits
Check your plan limits for:
- Blob storage (file count and size)
- KV operations (for resumable streams)
- AI Gateway usage
Troubleshooting
Cron job not running
Cron job not running
- Verify
CRON_SECRETis set in environment variables - Check Vercel dashboard → Logs → filter by
/api/cron - Crons only run in production (not preview deployments)
Blob upload fails
Blob upload fails
- Ensure
BLOB_READ_WRITE_TOKENis set - Check blob storage isn’t at capacity
- Verify file size is under 500MB limit
Code execution times out
Code execution times out
- Default timeout is 5 minutes
- Check sandbox logs in Vercel dashboard
- Ensure OIDC is working (automatic on Vercel)