@@ -30,6 +30,7 @@ describe("OpenRouter API", () => {
3030 supportsReasoningEffort : false ,
3131 supportsNativeTools : true ,
3232 supportedParameters : [ "max_tokens" , "temperature" , "reasoning" , "include_reasoning" ] ,
33+ defaultToolProtocol : "native" ,
3334 } )
3435
3536 expect ( models [ "anthropic/claude-3.7-sonnet:thinking" ] ) . toEqual ( {
@@ -47,6 +48,7 @@ describe("OpenRouter API", () => {
4748 supportsReasoningEffort : true ,
4849 supportsNativeTools : true ,
4950 supportedParameters : [ "max_tokens" , "temperature" , "reasoning" , "include_reasoning" ] ,
51+ defaultToolProtocol : "native" ,
5052 } )
5153
5254 expect ( models [ "google/gemini-2.5-flash-preview-05-20" ] . maxTokens ) . toEqual ( 65535 )
@@ -390,5 +392,55 @@ describe("OpenRouter API", () => {
390392 expect ( textResult . maxTokens ) . toBe ( 64000 )
391393 expect ( imageResult . maxTokens ) . toBe ( 64000 )
392394 } )
395+
396+ it ( "sets defaultToolProtocol to native when model supports native tools" , ( ) => {
397+ const mockModel = {
398+ name : "Tools Model" ,
399+ description : "Model with native tool support" ,
400+ context_length : 128000 ,
401+ max_completion_tokens : 8192 ,
402+ pricing : {
403+ prompt : "0.000003" ,
404+ completion : "0.000015" ,
405+ } ,
406+ }
407+
408+ const resultWithTools = parseOpenRouterModel ( {
409+ id : "test/tools-model" ,
410+ model : mockModel ,
411+ inputModality : [ "text" ] ,
412+ outputModality : [ "text" ] ,
413+ maxTokens : 8192 ,
414+ supportedParameters : [ "tools" , "max_tokens" , "temperature" ] ,
415+ } )
416+
417+ expect ( resultWithTools . supportsNativeTools ) . toBe ( true )
418+ expect ( resultWithTools . defaultToolProtocol ) . toBe ( "native" )
419+ } )
420+
421+ it ( "does not set defaultToolProtocol when model does not support native tools" , ( ) => {
422+ const mockModel = {
423+ name : "No Tools Model" ,
424+ description : "Model without native tool support" ,
425+ context_length : 128000 ,
426+ max_completion_tokens : 8192 ,
427+ pricing : {
428+ prompt : "0.000003" ,
429+ completion : "0.000015" ,
430+ } ,
431+ }
432+
433+ const resultWithoutTools = parseOpenRouterModel ( {
434+ id : "test/no-tools-model" ,
435+ model : mockModel ,
436+ inputModality : [ "text" ] ,
437+ outputModality : [ "text" ] ,
438+ maxTokens : 8192 ,
439+ supportedParameters : [ "max_tokens" , "temperature" ] ,
440+ } )
441+
442+ expect ( resultWithoutTools . supportsNativeTools ) . toBe ( false )
443+ expect ( resultWithoutTools . defaultToolProtocol ) . toBeUndefined ( )
444+ } )
393445 } )
394446} )
0 commit comments