@@ -35,13 +35,15 @@ local defaults = {
3535 message .content = message .content :gsub (" ^%s*(.-)%s*$" , " %1" )
3636 end
3737
38- -- TODO: Remove later --
39- -- Changes according to beta limitations of the OpenAI reasoning API
40- if payload .model and string.match (payload .model , " o[134]" ) then
41- -- remove system prompt
38+ -- OpenAI reasoning models (o1, o3, o4) have specific parameter requirements
39+ -- These models don't support system prompts or certain sampling parameters
40+ -- See: https://platform.openai.com/docs/guides/reasoning
41+ if payload .model and string.match (payload .model , " ^o[134]" ) then
42+ -- Remove system prompt as it's not supported by reasoning models
4243 if payload .messages [1 ] and payload .messages [1 ].role == " system" then
4344 table.remove (payload .messages , 1 )
4445 end
46+ -- Set fixed values for parameters that reasoning models don't support
4547 payload .temperature = 1
4648 payload .top_p = 1
4749 payload .presence_penalty = 0
@@ -367,8 +369,18 @@ function MultiProvider:curl_params()
367369
368370 for k , v in pairs (hdrs ) do
369371 table.insert (args , " -H" )
370- -- TODO: Check if this really makes sense to be a table --
371- local header_value = type (v ) == " table" and table.concat (v , " " ) or tostring (v )
372+ -- HTTP headers should always be strings, but handle edge cases defensively
373+ local header_value
374+ if type (v ) == " table" then
375+ logger .warning (" Header value is a table, this is likely a configuration error" , {
376+ provider = self .name ,
377+ header = k ,
378+ value = v ,
379+ })
380+ header_value = table.concat (v , " " )
381+ else
382+ header_value = tostring (v )
383+ end
372384 table.insert (args , k .. " : " .. header_value )
373385 end
374386 return args
@@ -427,8 +439,18 @@ function MultiProvider:get_available_models()
427439 -- Add headers to args
428440 for k , v in pairs (hdrs ) do
429441 table.insert (args , " -H" )
430- -- TODO: Check if this really makes sense to be a table --
431- local header_value = type (v ) == " table" and table.concat (v , " " ) or tostring (v )
442+ -- HTTP headers should always be strings, but handle edge cases defensively
443+ local header_value
444+ if type (v ) == " table" then
445+ logger .warning (" Header value is a table, this is likely a configuration error" , {
446+ provider = self .name ,
447+ header = k ,
448+ value = v ,
449+ })
450+ header_value = table.concat (v , " " )
451+ else
452+ header_value = tostring (v )
453+ end
432454 table.insert (args , k .. " : " .. header_value )
433455 end
434456
0 commit comments