Overview
chat.config.ts is the central configuration for ChatJS. It’s generated by the CLI (npx @chat-js/cli@latest create) from lib/config-schema.ts with sensible defaults and inline comments.
Access patterns
To access the config, import it from@/lib/config:
Configuration Shape
The schema is defined inlib/config-schema.ts. Each field’s .describe() comment appears as an inline comment in the generated config.
Gateway
Theai.gateway field determines which AI backend is used for model creation and model-list fetching. Validated at build time.
| Value | Backend | Required Env Vars |
|---|---|---|
"vercel" (default) | Vercel AI Gateway | AI_GATEWAY_API_KEY or VERCEL_OIDC_TOKEN |
"openrouter" | OpenRouter | OPENROUTER_API_KEY |
"openai" | OpenAI | OPENAI_API_KEY |
"openai-compatible" | OpenAI Compatible | OPENAI_COMPATIBLE_BASE_URL |
Feature flags + env validation
Feature flags live underai.tools, features, and authentication. They’re validated at build time by scripts/check-env.ts:
- Runs as
prebuildstep beforenext build - Missing env vars will fail the build immediately
Tool flags (ai.tools)
ai.tools.codeExecution.enabled: requiresVERCEL_OIDC_TOKEN(on Vercel) orVERCEL_TEAM_ID + VERCEL_PROJECT_ID + VERCEL_TOKEN(self-hosted)ai.tools.webSearch.enabled: requiresTAVILY_API_KEYorFIRECRAWL_API_KEYai.tools.urlRetrieval.enabled: requiresFIRECRAWL_API_KEY- fetch structured content from URLsai.tools.mcp.enabled: requiresMCP_ENCRYPTION_KEYai.tools.image.enabled: requiresBLOB_READ_WRITE_TOKEN- AI-powered image generation toolai.tools.video.enabled: requiresBLOB_READ_WRITE_TOKEN- AI-powered video generation toolai.tools.deepResearch.enabled: requires a configured search provider (TAVILY_API_KEYorFIRECRAWL_API_KEY)ai.tools.followupSuggestions.enabled: no extra env var, uses configured language model
Features
features.attachments: requiresBLOB_READ_WRITE_TOKEN- file uploads (images and PDFs)
Authentication
authentication.google: requiresAUTH_GOOGLE_ID + AUTH_GOOGLE_SECRETauthentication.github: requiresAUTH_GITHUB_ID + AUTH_GITHUB_SECRETauthentication.vercel: requiresVERCEL_APP_CLIENT_ID + VERCEL_APP_CLIENT_SECRET
Notes on behavior
- Anonymous limits:
anonymous.creditsand rate limits are typically higher in dev and lower in prod (seeconfig.anonymousimplementation). - Models:
ai.workflowsdefines shared workflow defaults,ai.tools.*.defaultdefines tool defaults,ai.disabledModelshard-hides models globally, andai.anonymousModelsconstrains what anonymous users can pick. - Deep research tuning: runtime knobs live under
ai.tools.deepResearch(allowClarification,maxResearcherIterations,maxConcurrentResearchUnits,maxSearchQueries).