@@ -321,3 +321,71 @@ describe("OpenRouterHandler", () => {
321321 } )
322322 } )
323323} )
324+
325+ describe ( "reasoning effort mapping (OpenRouter)" , ( ) => {
326+ it ( "passes 'minimal' through in reasoning.effort for OpenRouter requests" , async ( ) => {
327+ const handler = new OpenRouterHandler ( {
328+ openRouterApiKey : "test-key" ,
329+ openRouterModelId : "openai/o1-pro" ,
330+ reasoningEffort : "minimal" ,
331+ } as ApiHandlerOptions )
332+
333+ // Prepare a model that supports reasoning effort (not budget)
334+ ; ( handler as any ) . models = {
335+ "openai/o1-pro" : {
336+ maxTokens : 8192 ,
337+ contextWindow : 200000 ,
338+ supportsImages : true ,
339+ supportsPromptCache : true ,
340+ inputPrice : 0.0 ,
341+ outputPrice : 0.0 ,
342+ description : "o1-pro test" ,
343+ supportsReasoningEffort : true ,
344+ } ,
345+ }
346+
347+ // Ensure endpoints map is empty so base model info is used
348+ ; ( handler as any ) . endpoints = { }
349+
350+ // Mock OpenAI client call
351+ const mockCreate = vitest . fn ( ) . mockResolvedValue ( {
352+ async * [ Symbol . asyncIterator ] ( ) {
353+ yield {
354+ id : "openai/o1-pro" ,
355+ choices : [ { delta : { content : "ok" } } ] ,
356+ }
357+ yield {
358+ id : "usage-id" ,
359+ choices : [ { delta : { } } ] ,
360+ usage : { prompt_tokens : 1 , completion_tokens : 1 , cost : 0 } ,
361+ }
362+ } ,
363+ } )
364+ ; ( OpenAI as any ) . prototype . chat = {
365+ completions : { create : mockCreate } ,
366+ } as any
367+
368+ const systemPrompt = "system"
369+ const messages : Anthropic . Messages . MessageParam [ ] = [ { role : "user" , content : "hello" } ]
370+
371+ // Stub fetchModel to use the handler's getModel (which applies getModelParams -> getOpenRouterReasoning)
372+ const realGetModel = ( handler as any ) . getModel . bind ( handler )
373+ ; ( handler as any ) . fetchModel = vitest . fn ( ) . mockImplementation ( async ( ) => realGetModel ( ) )
374+
375+ // Trigger a request
376+ const gen = handler . createMessage ( systemPrompt , messages )
377+ // Drain iterator to ensure call is made
378+ for await ( const _ of gen ) {
379+ // noop
380+ }
381+
382+ // Verify the API call included the normalized effort
383+ expect ( mockCreate ) . toHaveBeenCalledWith (
384+ expect . objectContaining ( {
385+ model : "openai/o1-pro" ,
386+ reasoning : { effort : "minimal" } , // 'minimal' should be preserved for OpenRouter
387+ stream : true ,
388+ } ) ,
389+ )
390+ } )
391+ } )
0 commit comments