fix: skip temperature param for GPT-5 reasoning models
deploy / deploy (push) Has been cancelled

GPT-5/o-series models only support temperature=1 (default).
Sending temperature=0.3 (analytics) or temperature=0 (chart) causes
400 Bad Request: 'Unsupported value: temperature does not support X
with this model. Only the default (1) value is supported.'
Now temperature is omitted for gpt-5/o1/o3/o4 models.
This commit is contained in:
2026-08-15 06:26:04 +00:00
parent 1de740cc4b
commit fa21c7b83c
2 changed files with 6 additions and 2 deletions
@@ -84,7 +84,9 @@ public class OpenAIAnalyticsService {
requestBody.put("model", model); requestBody.put("model", model);
requestBody.put("messages", messages); requestBody.put("messages", messages);
requestBody.put("max_completion_tokens", maxTokens); requestBody.put("max_completion_tokens", maxTokens);
requestBody.put("temperature", temperature); if (!model.startsWith("gpt-5") && !model.startsWith("o1") && !model.startsWith("o3") && !model.startsWith("o4")) {
requestBody.put("temperature", temperature);
}
return requestBody; return requestBody;
} }
@@ -106,7 +106,9 @@ public class OpenAiChartService {
private Mono<String> callChatCompletions(String taskName, String prompt) { private Mono<String> callChatCompletions(String taskName, String prompt) {
Map<String, Object> body = new HashMap<>(); Map<String, Object> body = new HashMap<>();
body.put("model", modelName); body.put("model", modelName);
body.put("temperature", 0); if (!modelName.startsWith("gpt-5") && !modelName.startsWith("o1") && !modelName.startsWith("o3") && !modelName.startsWith("o4")) {
body.put("temperature", 0);
}
body.put("messages", List.of( body.put("messages", List.of(
Map.of("role", "user", "content", prompt))); Map.of("role", "user", "content", prompt)));