{"record":{"id":"cc836e576061be07","repo":"Mintplex-Labs/anything-llm","slug":"fireworksai-chat-this-model-is-not-valid-for-c","errorCode":null,"errorMessage":"FireworksAI chat: ${this.model} is not valid for chat completion!","messagePattern":"FireworksAI chat: (.+?) is not valid for chat completion!","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/AiProviders/fireworksAi/index.js","lineNumber":140,"sourceCode":"    return availableModels.hasOwnProperty(model);\n  }\n\n  constructPrompt({\n    systemPrompt = \"\",\n    contextTexts = [],\n    chatHistory = [],\n    userPrompt = \"\",\n  }) {\n    const prompt = {\n      role: \"system\",\n      content: `${systemPrompt}${this.#appendContext(contextTexts)}`,\n    };\n    return [prompt, ...chatHistory, { role: \"user\", content: userPrompt }];\n  }\n\n  async getChatCompletion(messages = null, { temperature = 0.7 }) {\n    if (!(await this.isValidChatCompletionModel(this.model)))\n      throw new Error(\n        `FireworksAI chat: ${this.model} is not valid for chat completion!`\n      );\n\n    const result = await LLMPerformanceMonitor.measureAsyncFunction(\n      this.openai.chat.completions.create({\n        model: this.model,\n        messages,\n        temperature,\n      })\n    );\n\n    if (\n      !result.output.hasOwnProperty(\"choices\") ||\n      result.output.choices.length === 0\n    )\n      return null;\n\n    return {","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/AiProviders/fireworksAi/index.js#L122-L158","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","solutions":["Query GET https://api.fireworks.ai/inference/v1/models with the API key to confirm the exact model id.","Delete storage/models/fireworks/models.json to force a cache refresh on the next sync.","Update FIREWORKS_AI_LLM_MODEL_PREF to a valid, currently-listed model id.","Ensure the storage directory is writable."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const llm = new FireworksAiLLM(embedder, modelPref);\nconst isValid = await llm.isValidChatCompletionModel(llm.model);\nif (!isValid)\n  throw new Error(`Model \"${llm.model}\" is not in the Fireworks catalog. Sync the cache or pick a valid id.`);","typeGuard":null,"tryCatchPattern":"try {\n  return await fireworks.getChatCompletion(messages, { temperature });\n} catch (e) {\n  if (/is not valid for chat completion/i.test(e.message)) {\n    fs.unlinkSync(path.resolve(cacheFolder, 'models.json'));\n    await fireworks.isValidChatCompletionModel(fireworks.model); // resync\n    return await fireworks.getChatCompletion(messages, { temperature });\n  }\n  throw e;\n}","preventionTips":["Sync the model cache after selecting a Fireworks model.","Ensure the storage/models/fireworks directory is writable.","Validate the model id against GET /inference/v1/models when saving settings."],"tags":["fireworks-ai","invalid-model","chat-completion","model-cache","validation"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}