Skip to content
ChatJS
Esc
navigateopen⌘Jpreview
On this page

Configuration

Customize ChatJS via chat.config.ts

All feature toggles and app settings live in chat.config.ts. It is parsed and exported as config from @/lib/config.

Config Structure

import type { ConfigInput } from "@/lib/config-schema";

const config: ConfigInput = {
  appName: "Your App Name",
  appPrefix: "your-app",

  organization: {
    name: "Your Company",
    contact: {
      privacyEmail: "privacy@example.com",
      legalEmail: "legal@example.com",
    },
  },

  ai: {
    gateway: "vercel", // "vercel" | "openrouter" | "openai" | "openai-compatible"
    tools: {
      webSearch: { enabled: true },
      urlRetrieval: { enabled: true },
      codeExecution: { enabled: true },
      mcp: { enabled: false },
      followupSuggestions: { enabled: true, default: "openai/gpt-5-nano" },
      image: { enabled: true },
      video: { enabled: true },
      deepResearch: {
        enabled: true,
        defaultModel: "google/gemini-2.5-flash-lite",
        finalReportModel: "google/gemini-3-flash",
        allowClarification: true,
        maxResearcherIterations: 1,
        maxConcurrentResearchUnits: 2,
        maxSearchQueries: 2,
      },
    },
  },

  features: {
    attachments: true, // File uploads (images and PDFs)
  },

  authentication: {
    google: true,
    github: true,
    vercel: false,
  },

  // ... more options
};

export default config;

AI Gateway

The ai.gateway field selects which AI backend to use. All model routing, fetching, and API calls go through the active gateway.

Value Backend Env Dependency
"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
"litellm" LiteLLM LITELLM_BASE_URL
ai: {
  gateway: "openrouter", // Switch to OpenRouter
  // ...
},

See Gateways for detailed setup and comparison.

Features

Toggle feature flags on/off. Tool flags live under ai.tools.*.enabled. features currently contains only attachments. Missing env vars are caught at build time via bun run prebuild.

Feature Config Key Env Dependency
Code Execution ai.tools.codeExecution.enabled VERCEL_OIDC_TOKEN (on Vercel) or VERCEL_TEAM_ID + VERCEL_PROJECT_ID + VERCEL_TOKEN
Web Search ai.tools.webSearch.enabled TAVILY_API_KEY or FIRECRAWL_API_KEY
URL Retrieval ai.tools.urlRetrieval.enabled FIRECRAWL_API_KEY
MCP Connectors ai.tools.mcp.enabled MCP_ENCRYPTION_KEY
Image Generation ai.tools.image.enabled Configured file storage provider
Video Generation ai.tools.video.enabled Configured file storage provider
Deep Research ai.tools.deepResearch.enabled TAVILY_API_KEY or FIRECRAWL_API_KEY
Follow-up Suggestions ai.tools.followupSuggestions.enabled Uses your configured language model provider
Attachments features.attachments Configured file storage provider
ai: {
  tools: {
    webSearch: { enabled: true },          // Requires TAVILY_API_KEY or FIRECRAWL_API_KEY
    urlRetrieval: { enabled: false },      // Requires FIRECRAWL_API_KEY
    codeExecution: { enabled: true },      // Vercel-native
    mcp: { enabled: false },               // Requires MCP_ENCRYPTION_KEY
    image: { enabled: true },              // Requires durable file storage
    video: { enabled: false },             // Requires durable file storage
    deepResearch: { enabled: false },      // Requires search provider
    followupSuggestions: { enabled: true } // Uses selected provider/model
  },
},
features: {
  attachments: true, // Requires durable file storage
},

Authentication

Set to true to enable providers. Missing env vars are caught at server startup.

authentication: {
  google: false, // Requires AUTH_GOOGLE_ID + AUTH_GOOGLE_SECRET
  github: true,  // Requires AUTH_GITHUB_ID + AUTH_GITHUB_SECRET
  vercel: false, // Requires VERCEL_APP_CLIENT_ID + VERCEL_APP_CLIENT_SECRET
},

Branding

Customize app name and organization details:

appName: "ChatJS",
appTitle: "ChatJS - The prod ready AI chat app",
appPrefix: "chatjs",

organization: {
  name: "Your Company",
  contact: {
    privacyEmail: "privacy@example.com",
    legalEmail: "legal@example.com",
  },
},

Deep Research

Configure the deep research pipeline in ai.tools.deepResearch:

ai: {
  tools: {
    deepResearch: {
      enabled: true,                   // Requires webSearch provider config
      defaultModel: "openai/gpt-5-mini",
      finalReportModel: "openai/gpt-5-mini",
      allowClarification: true,        // Ask clarifying questions before starting
      maxResearcherIterations: 1,      // Supervisor loop iterations
      maxConcurrentResearchUnits: 2,   // Topics researched in parallel
      maxSearchQueries: 2,             // Queries per research topic
    },
  },
},

See Deep Research for usage details.

Using Config in Components

Import directly in both server and client components:

import { config } from "@/lib/config";

export function MyComponent() {
  return <div>{config.appName}</div>;
}

See Config Reference for full type definitions.

Was this page helpful?