{"record":{"id":"28909f92f1139535","repo":"Mintplex-Labs/anything-llm","slug":"openai-chat-this-model-is-not-valid-for-chat-c","errorCode":null,"errorMessage":"OpenAI chat: ${this.model} is not valid for chat completion!","messagePattern":"OpenAI chat: (.+?) is not valid for chat completion!","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/AiProviders/openAi/index.js","lineNumber":150,"sourceCode":"   * @param {string} modelName\n   * @param {number} temperature\n   * @returns {number}\n   */\n  #temperature(modelName, temperature) {\n    // For models that don't support temperature\n    // OpenAI accepts temperature 1\n    const NO_TEMP_MODELS = [\"o\", \"gpt-5\"];\n\n    if (NO_TEMP_MODELS.some((prefix) => modelName.startsWith(prefix))) {\n      return 1;\n    }\n\n    return temperature;\n  }\n\n  async getChatCompletion(messages = null, { temperature = 0.7 }) {\n    if (!(await this.isValidChatCompletionModel(this.model)))\n      throw new Error(\n        `OpenAI chat: ${this.model} is not valid for chat completion!`\n      );\n\n    const result = await LLMPerformanceMonitor.measureAsyncFunction(\n      this.openai.responses\n        .create({\n          model: this.model,\n          input: messages,\n          store: false,\n          temperature: this.#temperature(this.model, temperature),\n        })\n        .catch((e) => {\n          throw new Error(e.message);\n        })\n    );\n\n    if (!result.output.hasOwnProperty(\"output_text\")) return null;\n","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/AiProviders/openAi/index.js#L132-L168","documentation":"Pre-flight guard in OpenAiLLM.getChatCompletion: the configured model failed the valid-model check against OpenAI's known models, so the request is rejected before calling the API with a model OpenAI would refuse.","triggerScenarios":"Thrown when the configured OpenAI model is not a chat model.","commonSituations":"Model preference set to an invalid or non-chat model.","solutions":["Select an OpenAI model valid for chat completion (e.g. gpt-4o)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}