Mintplex-Labs/anything-llm · error · Error
OpenAI chat: is not valid for chat completion!
Error message
OpenAI chat: ${this.model} is not valid for chat completion! What it means
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.
Solutions
- Select an OpenAI model valid for chat completion (e.g. gpt-4o).
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown when the configured OpenAI model is not a chat model.
Common situations: Model preference set to an invalid or non-chat model.
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/28909f92f1139535.
Report an issue: GitHub.
Appendix: source
Thrown at server/utils/AiProviders/openAi/index.js:150
* @param {string} modelName
* @param {number} temperature
* @returns {number}
*/
#temperature(modelName, temperature) {
// For models that don't support temperature
// OpenAI accepts temperature 1
const NO_TEMP_MODELS = ["o", "gpt-5"];
if (NO_TEMP_MODELS.some((prefix) => modelName.startsWith(prefix))) {
return 1;
}
return temperature;
}
async getChatCompletion(messages = null, { temperature = 0.7 }) {
if (!(await this.isValidChatCompletionModel(this.model)))
throw new Error(
`OpenAI chat: ${this.model} is not valid for chat completion!`
);
const result = await LLMPerformanceMonitor.measureAsyncFunction(
this.openai.responses
.create({
model: this.model,
input: messages,
store: false,
temperature: this.#temperature(this.model, temperature),
})
.catch((e) => {
throw new Error(e.message);
})
);
if (!result.output.hasOwnProperty("output_text")) return null;
View on GitHub (pinned to 3aec848f28)