Scaling AI Capabilities: Centralizing Model Management in Dyad
Introduction
As we continue to grow the capabilities within the Dyad project, managing multiple AI model providers has become increasingly complex. To ensure a performant and maintainable architecture, we recently focused on centralizing our model and provider configurations.
The Problem
Previously, AI model configuration was scattered across various helper utilities and UI components. As we introduced new, specialized models like "Dyad Turbo"—our high-performance, cost-effective tier—the lack of a single source of truth created several issues:
- Inconsistent model naming and provider labels across the interface.
- Difficulty in applying conditional gating (e.g., exposing Pro-only models).
- Maintenance overhead when adding new model providers like Kimi or Qwen.
The Solution: Centralized Provider Constants
We refactored our architecture to move all model and provider definitions into a single source of truth: language_model_constants.ts. This allows us to handle feature flags and provider settings in one place, ensuring the UI stays synced with our backend logic.
// language_model_constants.ts
export const AVAILABLE_MODELS = {
TURBO_QWEN: { id: 'qwen-3-coder', isPro: true, label: 'Qwen Turbo' },
TURBO_KIMI: { id: 'kimi-k2', isPro: true, label: 'Kimi Turbo' },
SMART_AUTO: { id: 'smart-auto', isPro: false, label: 'Smart Auto' },
};
export const getAccessibleModels = (isUserPro: boolean) => {
return Object.values(AVAILABLE_MODELS).filter(
(model) => !model.isPro || isUserPro
);
};
This centralized constant file now powers our ModelPicker component, providing a clean separation between the UI presentation and the provider configuration. By centralizing these definitions, we can now easily manage "Pro-only" badges and feature gating without touching individual component files.
Results
By unifying our configuration management, we achieved:
- Streamlined UI Updates: Adding a new provider now requires updating a single file rather than multiple UI components.
- Consistent Gating: The Pro-tier access logic is now standardized, ensuring non-Pro users never accidentally see exclusive high-performance options.
- Cleaner Codebase: Removed redundant logic from helpers, client utilities, and thinking modules.
Getting Started
- Audit your AI integrations to identify where provider constants are hardcoded.
- Create a centralized configuration file for your models.
- Implement a simple helper function to filter available models based on user permissions or feature flags.
Key Insight
When scaling complex integrations like AI models, centralizing your configuration is more than just clean code—it is a defensive measure against feature creep and technical debt. Treat your model definitions as configuration data rather than implementation details.
Generated with Gitvlg.com