ruvnet/ruflo · error
Model is required for ${this.name} provider
Error message
Model is required for ${this.name} provider What it means
BaseProvider.initialize() runs validateConfig() before any network call; if the provider config has no `model`, this error is thrown at startup. The model selects which LLM every request uses (e.g. 'gpt-4o', 'claude-sonnet-4'), so it is mandatory for all providers.
Source
Thrown at v3/@claude-flow/providers/src/base-provider.ts:194
if (this.config.enableCaching) {
this.startHealthChecks();
}
// Initial health check
await this.healthCheck();
}
/**
* Provider-specific initialization (override in subclass)
*/
protected abstract doInitialize(): Promise<void>;
/**
* Validate provider configuration
*/
protected validateConfig(): void {
if (!this.config.model) {
throw new Error(`Model is required for ${this.name} provider`);
}
if (!this.validateModel(this.config.model)) {
this.logger.warn(`Model ${this.config.model} may not be supported by ${this.name}`);
}
if (this.config.temperature !== undefined) {
if (this.config.temperature < 0 || this.config.temperature > 2) {
throw new Error('Temperature must be between 0 and 2');
}
}
}
/**
* Complete a request
*/
async complete(request: LLMRequest): Promise<LLMResponse> {
const startTime = Date.now();View on GitHub (pinned to fa13ee4ad6)
Solutions
- Add `model` to the provider config: config: { apiKey, model: 'gpt-4o' }
- If the model comes from an env var, verify it is actually exported in the shell/.env the process loads (printenv | grep MODEL)
- Default it early - model: process.env.OPENAI_MODEL ?? 'gpt-4o-mini' - so a missing env var can never reach the provider
- Type your config as the package's LLMProviderConfig so TypeScript flags the missing field before runtime
Example fix
// before
const provider = new OpenAIProvider({
name: 'openai',
config: { apiKey: process.env.OPENAI_API_KEY }, // no model -> throws at initialize()
});
await provider.initialize();
// after
const provider = new OpenAIProvider({
name: 'openai',
config: {
apiKey: process.env.OPENAI_API_KEY,
model: process.env.OPENAI_MODEL ?? 'gpt-4o',
},
});
await provider.initialize(); Defensive patterns
Strategy: validation
Validate before calling
function assertValidProviderConfig(config: LLMProviderConfig): void {
if (!config.model || typeof config.model !== 'string') {
throw new Error(`Missing required config.model for provider '${config.provider}'`);
}
} Type guard
interface ConfigWithModel extends LLMProviderConfig { model: string }
function hasModel(cfg: LLMProviderConfig): cfg is ConfigWithModel {
return typeof cfg.model === 'string' && cfg.model.length > 0;
} Try / catch
try {
await provider.initialize();
} catch (e) {
if (e instanceof Error && e.message.startsWith('Model is required')) {
// config bug: surface immediately, do not retry
throw new ConfigError('provider config missing model', { cause: e });
}
throw e;
} Prevention
- Type config objects as LLMProviderConfig so missing fields fail at compile time
- Apply env-derived values through a default (?? 'gpt-4o-mini') instead of passing raw
- Run a startup config assertion before initializing any provider
When it happens
Trigger: Constructing and initializing any provider with a config whose `model` is missing, undefined or empty - e.g. new OpenAIProvider({ name: 'openai', config: { apiKey } }) with no model, or model read from an unset env var.
Common situations: Model sourced from an unset OPENAI_MODEL / ANTHROPIC_MODEL env var; using `modelId` or `modelName` instead of `model`; a config merge/spread that overwrites model with undefined; scaffolding copied from an example that omitted the field.
Related errors
- Unknown provider: ${config.provider}
- localCompute: no adapter for graphId=${input.graphId}
- RuvllmConfig.modelsDir is required
- dimension is required when creating a new memory file
- Key exceeds maximum nesting depth of ${MAX_NESTING_DEPTH}
AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18).
Data as JSON: /api/errors/f61303b1ecbd6a22.
Report an issue: GitHub.