@@ -129,6 +129,27 @@ export class OpenAiHandler extends BaseProvider implements SingleCompletionHandl
129129 stream : true as const ,
130130 stream_options : { include_usage : true } ,
131131 }
132+
133+ // Add min_p if set
134+ if ( this . options . modelMinP !== undefined && this . options . modelMinP !== null ) {
135+ ; ( requestOptions as any ) . min_p = this . options . modelMinP
136+ }
137+
138+ // Add max_p (top_p) if set
139+ if ( this . options . modelMaxP !== undefined && this . options . modelMaxP !== null ) {
140+ requestOptions . top_p = this . options . modelMaxP
141+ }
142+
143+ // Add top_k if set
144+ if ( this . options . modelTopK !== undefined && this . options . modelTopK !== null ) {
145+ ; ( requestOptions as any ) . top_k = this . options . modelTopK
146+ }
147+
148+ // Add repetition_penalty if set
149+ if ( this . options . modelRepetitionPenalty !== undefined && this . options . modelRepetitionPenalty !== null ) {
150+ requestOptions . frequency_penalty = this . options . modelRepetitionPenalty - 1.0
151+ }
152+
132153 if ( this . options . includeMaxTokens ) {
133154 requestOptions . max_tokens = modelInfo . maxTokens
134155 }
@@ -184,6 +205,27 @@ export class OpenAiHandler extends BaseProvider implements SingleCompletionHandl
184205 messages : deepseekReasoner
185206 ? convertToR1Format ( [ { role : "user" , content : systemPrompt } , ...messages ] )
186207 : [ systemMessage , ...convertToOpenAiMessages ( messages ) ] ,
208+ temperature : this . options . modelTemperature ?? ( deepseekReasoner ? DEEP_SEEK_DEFAULT_TEMPERATURE : 0 ) ,
209+ }
210+
211+ // Add min_p if set
212+ if ( this . options . modelMinP !== undefined && this . options . modelMinP !== null ) {
213+ ; ( requestOptions as any ) . min_p = this . options . modelMinP
214+ }
215+
216+ // Add max_p (top_p) if set
217+ if ( this . options . modelMaxP !== undefined && this . options . modelMaxP !== null ) {
218+ requestOptions . top_p = this . options . modelMaxP
219+ }
220+
221+ // Add top_k if set
222+ if ( this . options . modelTopK !== undefined && this . options . modelTopK !== null ) {
223+ ; ( requestOptions as any ) . top_k = this . options . modelTopK
224+ }
225+
226+ // Add repetition_penalty if set
227+ if ( this . options . modelRepetitionPenalty !== undefined && this . options . modelRepetitionPenalty !== null ) {
228+ requestOptions . frequency_penalty = this . options . modelRepetitionPenalty - 1.0
187229 }
188230
189231 const response = await this . client . chat . completions . create ( requestOptions )
@@ -216,6 +258,27 @@ export class OpenAiHandler extends BaseProvider implements SingleCompletionHandl
216258 const requestOptions : OpenAI . Chat . Completions . ChatCompletionCreateParamsNonStreaming = {
217259 model : this . getModel ( ) . id ,
218260 messages : [ { role : "user" , content : prompt } ] ,
261+ temperature : this . options . modelTemperature ?? 0 ,
262+ }
263+
264+ // Add min_p if set
265+ if ( this . options . modelMinP !== undefined && this . options . modelMinP !== null ) {
266+ ; ( requestOptions as any ) . min_p = this . options . modelMinP
267+ }
268+
269+ // Add max_p (top_p) if set
270+ if ( this . options . modelMaxP !== undefined && this . options . modelMaxP !== null ) {
271+ requestOptions . top_p = this . options . modelMaxP
272+ }
273+
274+ // Add top_k if set
275+ if ( this . options . modelTopK !== undefined && this . options . modelTopK !== null ) {
276+ ; ( requestOptions as any ) . top_k = this . options . modelTopK
277+ }
278+
279+ // Add repetition_penalty if set
280+ if ( this . options . modelRepetitionPenalty !== undefined && this . options . modelRepetitionPenalty !== null ) {
281+ requestOptions . frequency_penalty = this . options . modelRepetitionPenalty - 1.0
219282 }
220283
221284 const response = await this . client . chat . completions . create ( requestOptions )
@@ -234,7 +297,7 @@ export class OpenAiHandler extends BaseProvider implements SingleCompletionHandl
234297 messages : Anthropic . Messages . MessageParam [ ] ,
235298 ) : ApiStream {
236299 if ( this . options . openAiStreamingEnabled ?? true ) {
237- const stream = await this . client . chat . completions . create ( {
300+ const streamOptions : OpenAI . Chat . Completions . ChatCompletionCreateParamsStreaming = {
238301 model : "o3-mini" ,
239302 messages : [
240303 {
@@ -243,10 +306,33 @@ export class OpenAiHandler extends BaseProvider implements SingleCompletionHandl
243306 } ,
244307 ...convertToOpenAiMessages ( messages ) ,
245308 ] ,
246- stream : true ,
309+ stream : true as const ,
247310 stream_options : { include_usage : true } ,
248311 reasoning_effort : this . getModel ( ) . info . reasoningEffort ,
249- } )
312+ temperature : this . options . modelTemperature ?? 0 ,
313+ } as any
314+
315+ // Add min_p if set
316+ if ( this . options . modelMinP !== undefined && this . options . modelMinP !== null ) {
317+ ; ( streamOptions as any ) . min_p = this . options . modelMinP
318+ }
319+
320+ // Add max_p (top_p) if set
321+ if ( this . options . modelMaxP !== undefined && this . options . modelMaxP !== null ) {
322+ streamOptions . top_p = this . options . modelMaxP
323+ }
324+
325+ // Add top_k if set
326+ if ( this . options . modelTopK !== undefined && this . options . modelTopK !== null ) {
327+ ; ( streamOptions as any ) . top_k = this . options . modelTopK
328+ }
329+
330+ // Add repetition_penalty if set
331+ if ( this . options . modelRepetitionPenalty !== undefined && this . options . modelRepetitionPenalty !== null ) {
332+ streamOptions . frequency_penalty = this . options . modelRepetitionPenalty - 1.0
333+ }
334+
335+ const stream = await this . client . chat . completions . create ( streamOptions )
250336
251337 yield * this . handleStreamResponse ( stream )
252338 } else {
@@ -259,6 +345,27 @@ export class OpenAiHandler extends BaseProvider implements SingleCompletionHandl
259345 } ,
260346 ...convertToOpenAiMessages ( messages ) ,
261347 ] ,
348+ temperature : this . options . modelTemperature ?? 0 ,
349+ }
350+
351+ // Add min_p if set
352+ if ( this . options . modelMinP !== undefined && this . options . modelMinP !== null ) {
353+ ; ( requestOptions as any ) . min_p = this . options . modelMinP
354+ }
355+
356+ // Add max_p (top_p) if set
357+ if ( this . options . modelMaxP !== undefined && this . options . modelMaxP !== null ) {
358+ requestOptions . top_p = this . options . modelMaxP
359+ }
360+
361+ // Add top_k if set
362+ if ( this . options . modelTopK !== undefined && this . options . modelTopK !== null ) {
363+ ; ( requestOptions as any ) . top_k = this . options . modelTopK
364+ }
365+
366+ // Add repetition_penalty if set
367+ if ( this . options . modelRepetitionPenalty !== undefined && this . options . modelRepetitionPenalty !== null ) {
368+ requestOptions . frequency_penalty = this . options . modelRepetitionPenalty - 1.0
262369 }
263370
264371 const response = await this . client . chat . completions . create ( requestOptions )
0 commit comments