Skip to main content
Vercel is the recommended deployment platform. It provides integrated storage, AI Gateway, and edge infrastructure with zero configuration.
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.
IntegrationPurposeRequired
Vercel Postgres or NeonPrimary databaseYes
Vercel BlobFile attachments, generated imagesIf using attachments/image gen
Vercel KVResumable streams (Redis)Optional
AI GatewayUnified access to 120+ AI modelsYes

AI Gateway

AI Gateway provides a single API key to access models from OpenAI, Anthropic, Google, and more.
  1. Go to Vercel AI Gateway
  2. Create an API key
  3. Add to environment: AI_GATEWAY_API_KEY
See Multi-Model Support for configuring available models.

Blob Storage

Required for file attachments and AI image generation.
  1. Go to StorageCreateBlob
  2. Connect to your project
  3. Environment variable BLOB_READ_WRITE_TOKEN is auto-added
To disable blob features, set in chat.config.ts:
integrations: {
  attachments: false,
  imageGeneration: false,
}

KV (Redis)

Enables resumable streams - users can refresh the page mid-generation and continue where they left off.
  1. Go to StorageCreateKV
  2. Connect to your project
  3. Environment variable REDIS_URL is auto-added
Without Redis, streams work normally but can’t be resumed after disconnection.

Cron Jobs

ChatJS includes a daily cleanup job that removes orphaned blob attachments (uploaded but never saved to a message).

Configuration

Defined in vercel.json:
{
  "crons": [
    {
      "path": "/api/cron/cleanup",
      "schedule": "0 2 * * *"
    }
  ]
}
Runs daily at 2 AM UTC. Adjust the schedule using cron syntax.

Security

The cron endpoint requires a CRON_SECRET environment variable:
# Generate a secret
openssl rand -base64 32
Add to Vercel environment variables. Vercel automatically sends this as a Bearer token.

Customizing Cleanup

Edit app/api/cron/cleanup/route.ts to add cleanup tasks:
const results = {
  orphanedAttachments: await cleanupOrphanedAttachments(),
  // Add other cleanup tasks here
  expiredSessions: await cleanupExpiredSessions(),
};

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:
VERCEL_TEAM_ID=team_xxx
VERCEL_PROJECT_ID=prj_xxx
VERCEL_TOKEN=xxx

Runtime Configuration

Set the Python version via environment variable:
VERCEL_SANDBOX_RUNTIME=python3.13  # default

Resource Limits

Sandboxes run with:
  • 2 vCPUs
  • 5 minute timeout
  • Pre-installed: matplotlib, pandas, numpy, sympy, yfinance

Environment Variables

Required

VariableDescription
DATABASE_URLPostgreSQL connection string
AUTH_SECRETSession encryption key
AI_GATEWAY_API_KEYVercel AI Gateway key

Optional (Vercel Features)

VariableFeature
BLOB_READ_WRITE_TOKENBlob storage (auto-set by integration)
REDIS_URLKV/Redis for resumable streams
CRON_SECRETSecure cron endpoint

Pull from Vercel

After linking your project, pull all environment variables:
vercel link
vercel env pull .env.local

Production Checklist

Before going live:
  1. Go to SettingsDomains
  2. Add your custom domain
  3. Update OAuth callback URLs to use the new domain
Update your OAuth apps (GitHub, Google) with production callback URLs:
https://yourdomain.com/api/auth/callback/github
https://yourdomain.com/api/auth/callback/google
Check your plan limits for:
  • Blob storage (file count and size)
  • KV operations (for resumable streams)
  • AI Gateway usage

Troubleshooting

  • Verify CRON_SECRET is set in environment variables
  • Check Vercel dashboard → Logs → filter by /api/cron
  • Crons only run in production (not preview deployments)
  • Ensure BLOB_READ_WRITE_TOKEN is set
  • Check blob storage isn’t at capacity
  • Verify file size is under 500MB limit
  • Default timeout is 5 minutes
  • Check sandbox logs in Vercel dashboard
  • Ensure OIDC is working (automatic on Vercel)