Mintplex-Labs/anything-llm · error · Error

FireworksAI chat: ${this.model} is not valid for chat comple

Error message

FireworksAI chat: ${this.model} is not valid for chat completion!

What it means

Thrown by getChatCompletion when isValidChatCompletionModel returns false. The validator syncs the local cache (storage/models/fireworks/models.json) from Fireworks AI's /models endpoint, then checks whether this.model is a property key in the cached object. If the model is absent — stale/missing cache or invalid/deprecated model id — the non-streaming chat is blocked.

Source

Thrown at server/utils/AiProviders/fireworksAi/index.js:140

    return availableModels.hasOwnProperty(model);
  }

  constructPrompt({
    systemPrompt = "",
    contextTexts = [],
    chatHistory = [],
    userPrompt = "",
  }) {
    const prompt = {
      role: "system",
      content: `${systemPrompt}${this.#appendContext(contextTexts)}`,
    };
    return [prompt, ...chatHistory, { role: "user", content: userPrompt }];
  }

  async getChatCompletion(messages = null, { temperature = 0.7 }) {
    if (!(await this.isValidChatCompletionModel(this.model)))
      throw new Error(
        `FireworksAI chat: ${this.model} is not valid for chat completion!`
      );

    const result = await LLMPerformanceMonitor.measureAsyncFunction(
      this.openai.chat.completions.create({
        model: this.model,
        messages,
        temperature,
      })
    );

    if (
      !result.output.hasOwnProperty("choices") ||
      result.output.choices.length === 0
    )
      return null;

    return {

View on GitHub (pinned to 526360e320)

Solutions

  1. Query GET https://api.fireworks.ai/inference/v1/models with the API key to confirm the exact model id.
  2. Delete storage/models/fireworks/models.json to force a cache refresh on the next sync.
  3. Update FIREWORKS_AI_LLM_MODEL_PREF to a valid, currently-listed model id.
  4. Ensure the storage directory is writable.
Defensive patterns

Strategy: validation

Validate before calling

const llm = new FireworksAiLLM(embedder, modelPref);
const isValid = await llm.isValidChatCompletionModel(llm.model);
if (!isValid)
  throw new Error(`Model "${llm.model}" is not in the Fireworks catalog. Sync the cache or pick a valid id.`);

Try / catch

try {
  return await fireworks.getChatCompletion(messages, { temperature });
} catch (e) {
  if (/is not valid for chat completion/i.test(e.message)) {
    fs.unlinkSync(path.resolve(cacheFolder, 'models.json'));
    await fireworks.isValidChatCompletionModel(fireworks.model); // resync
    return await fireworks.getChatCompletion(messages, { temperature });
  }
  throw e;
}

Prevention

When it happens

Trigger: FIREWORKS_AI_LLM_MODEL_PREF is set to a model id not in the Fireworks catalog (e.g. a typo, wrong casing, or retired model); models.json does not exist or is empty because the initial sync failed; the storage directory is unwritable so the cache was never created.

Common situations: First FireworksAI request on a fresh install before the model cache syncs; Fireworks retiring a model after the preference was saved; the model id uses a different prefix format (e.g. 'accounts/fireworks/models/...' vs the bare id).

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/cc836e576061be07. Report an issue: GitHub.