fix(llm): use max_completion_tokens instead of deprecated max_tokens for OpenAI requests

Fixes #30 — newer OpenAI models (o1, o3, o4, gpt-5.x) reject the
deprecated max_tokens parameter with a 400 error.
This commit is contained in:
kite 2026-06-07 08:32:47 +08:00
parent 8d187f607f
commit 5fad9ce2fa

View file

@ -390,7 +390,7 @@ func (c *OpenAIClient) buildOpenAIParams(model string, req ChatRequest) openai.C
params.Tools = tools
}
if req.MaxTokens > 0 {
params.MaxTokens = openai.Int(int64(req.MaxTokens))
params.MaxCompletionTokens = openai.Int(int64(req.MaxTokens))
}
if req.Temperature != nil {
params.Temperature = openai.Float(*req.Temperature)