Provider abstraction
The AI layer is built on the Vercel AI SDK v4.3 and abstracts away provider differences behind a unified interface. Switching between OpenAI, Anthropic, Google, and xAI requires changing a single environment variable — the rest of the application remains untouched.
# Switch providers without code changes
AI_PROVIDER=openai # GPT-5, GPT-4.1, o3, o4-mini
AI_PROVIDER=anthropic # Claude Opus 4.5, Claude Sonnet 4.5, Claude Haiku 4.5
AI_PROVIDER=google # Gemini 2.5 Pro, Gemini 2.5 Flash, Gemini 3 Flash Preview
AI_PROVIDER=xai # Grok 4.1 Fast Reasoning
Reasoning model support
Reasoning models like GPT-5 and the o-series require different parameter handling than standard models. The system detects reasoning models automatically and adjusts accordingly — temperature is skipped (these models ignore it) and maxTokens is increased to 16384 to leave room for both internal reasoning and visible output. Without this adjustment, reasoning tokens consume the entire budget and the response comes back empty.
Feature flags
Each AI capability — LLM chat, RAG chat, vision, PDF analysis — is controlled by an independent feature flag. This allows gradual rollout, A/B testing, or disabling specific features without affecting others. Flags are checked at both the UI and API layer to prevent unauthorized access to disabled features.