thedotmack/claude-mem · info

Invalid Gemini model

Error message

Invalid Gemini model "${configuredModel}", falling back to ${defaultModel}

What it means

This warning fires in getGeminiConfig when the configured Gemini model name is not in the list of valid GeminiModel values. Instead of failing, the provider falls back to defaultModel so the session can still run. It indicates a configuration typo or an unsupported/outdated model string.

Solutions

  1. Set the model to one of the values listed in validModels in the log payload.
  2. Update the library to a version that supports the desired Gemini model.
  3. Remove the explicit model config to accept the defaultModel.
  4. Check for casing/typo mistakes against the GeminiModel type definition.

Example fix

// before
GEMINI_MODEL=gemini-1.5-pro-latest
// after
GEMINI_MODEL=gemini-1.5-pro
Defensive patterns

Strategy: validation

Validate before calling

import { GeminiModel } from './GeminiProvider';
const VALID = ['gemini-2.0-flash','gemini-1.5-pro' /* per validModels */];
if (!VALID.includes(process.env.GEMINI_MODEL)) {
  console.warn(`Unknown model ${process.env.GEMINI_MODEL}, default will be used`);
}

Type guard

const isGeminiModel = (m: string): m is GeminiModel =>
  validModels.includes(m as GeminiModel);

Prevention

When it happens

Trigger: getGeminiConfig reads the configured model and validModels.includes(configuredModel) is false — e.g. model set to a name not in the validModels array.

Common situations: Typo in config (e.g. 'gemini-pro-1.5' vs 'gemini-1.5-pro'); using a model name from a newer Gemini release before the library supports it; environment/config value copied from another provider.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of thedotmack/claude-mem@d8bc9755e7 (2026-09-17). Data as JSON: /api/errors/6a0a763c43fd9d9b. Report an issue: GitHub.

Appendix: source

Thrown at src/services/worker/GeminiProvider.ts:413

    const settings = SettingsDefaultsManager.loadFromFile(settingsPath);

    const apiKey = settings.CLAUDE_MEM_GEMINI_API_KEY || getCredential('GEMINI_API_KEY') || '';

    const defaultModel: GeminiModel = 'gemini-flash-latest';
    const configuredModel = settings.CLAUDE_MEM_GEMINI_MODEL || defaultModel;
    const validModels: GeminiModel[] = [
      'gemini-flash-latest',
      'gemini-flash-lite-latest',
      'gemini-3.5-flash',
      'gemini-3.1-flash-lite',
      'gemini-3-flash-preview',
    ];

    let model: GeminiModel;
    if (validModels.includes(configuredModel as GeminiModel)) {
      model = configuredModel as GeminiModel;
    } else {
      logger.warn('SDK', `Invalid Gemini model "${configuredModel}", falling back to ${defaultModel}`, {
        configured: configuredModel,
        validModels,
      });
      model = defaultModel;
    }

    const rateLimitingEnabled = settings.CLAUDE_MEM_GEMINI_RATE_LIMITING_ENABLED !== 'false';

    return { apiKey, model, rateLimitingEnabled };
  }
}

export function isGeminiAvailable(): boolean {
  const settingsPath = paths.settings();
  const settings = SettingsDefaultsManager.loadFromFile(settingsPath);
  return !!(settings.CLAUDE_MEM_GEMINI_API_KEY || getCredential('GEMINI_API_KEY'));
}

View on GitHub (pinned to d8bc9755e7)