Mintplex-Labs/anything-llm · error · Error

FireworksAI chat: is not valid for chat completion!

Error message

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

What it means

FireworksAiLLM.getChatCompletion validates this.model against the locally cached Fireworks catalog (storage/models/fireworks/models.json, refreshed via #syncModels) before sending a request. If the model id is not a key in that catalog, the request is rejected pre-flight with this error. This mirrors the streaming guard at line 175 and exists because Fireworks would otherwise return an opaque 404 from its inference API.

Solutions

  1. Set the model to a currently served Fireworks id (e.g. accounts/fireworks/models/llama-v3p1-8b-instruct) via the workspace model preference or FIREWORKS_AI_LLM_MODEL_PREF
  2. Delete the stale cache (storage/models/fireworks/models.json and .cached_at) and retry so #syncModels refetches the live catalog
  3. Check the exact id casing/whitespace in the saved preference — the check is a plain object-key lookup, so exact match is required
  4. List valid ids with a direct call: curl -H "Authorization: Bearer $FIREWORKS_AI_LLM_API_KEY" https://api.fireworks.ai/inference/v1/models

Example fix

// before
this.model = "llama-3.1-8b"; // not a real catalog id

// after
this.model = "accounts/fireworks/models/llama-v3p1-8b-instruct";
Defensive patterns

Strategy: validation

Validate before calling

// use the provider's own catalog check before sending the real prompt
const ok = await llm.isValidChatCompletionModel(llm.model);
if (!ok) {
  const available = Object.keys(llm.models());
  return respond(`Model '${llm.model}' unavailable. Pick from: ${available.join(", ")}`);
}
await llm.getChatCompletion(messages);

Try / catch

try {
  await llm.getChatCompletion(messages);
} catch (err) {
  if (err.message.includes("is not valid for chat completion")) {
    // refresh catalog + prompt re-selection; do not blind-retry
    fs.rmSync("storage/models/fireworks/models.json", { force: true });
    return respond("Model no longer available — pick another FireworksAI model.");
  }
  throw err;
}

Prevention

When it happens

Trigger: getChatCompletion() called with this.model set to an id that is not in models.json — e.g. a deprecated/renamed model, a typo in FIREWORKS_AI_LLM_MODEL_PREF or the workspace modelPreference, or a catalog that is stale because the cache file could not be refreshed (offline server, read-only storage) and predates the model you selected.

Common situations: Fireworks deprecates or renames a model after you pinned it in a workspace; a hand-edited models.json cache is stale; the server had no network when the cache was last written so newer models never appeared; modelPreference passed from the UI contains extra whitespace or wrong casing.

Related errors


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

Appendix: 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 3aec848f28)