@@ -514,3 +514,109 @@ describe("useSelectedModel", () => {
514514 } )
515515 } )
516516} )
517+
518+ describe ( "vertex provider pricing with region and [1m] tiers" , ( ) => {
519+ beforeEach ( ( ) => {
520+ // Keep other hooks stable/inert for Vertex path
521+ ; ( mockUseRouterModels as any ) . mockReturnValue ( {
522+ data : { openrouter : { } , requesty : { } , glama : { } , unbound : { } , litellm : { } , "io-intelligence" : { } } ,
523+ isLoading : false ,
524+ isError : false ,
525+ } )
526+ ; ( mockUseOpenRouterModelProviders as any ) . mockReturnValue ( {
527+ data : { } ,
528+ isLoading : false ,
529+ isError : false ,
530+ } )
531+ } )
532+
533+ it ( "applies global pricing for Sonnet 4 under 200k (no [1m])" , ( ) => {
534+ const apiConfiguration : ProviderSettings = {
535+ apiProvider : "vertex" ,
536+ apiModelId : "claude-sonnet-4@20250514" ,
537+ vertexRegion : "global" ,
538+ }
539+
540+ const wrapper = createWrapper ( )
541+ const { result } = renderHook ( ( ) => useSelectedModel ( apiConfiguration ) , { wrapper } )
542+
543+ expect ( result . current . provider ) . toBe ( "vertex" )
544+ expect ( result . current . id ) . toBe ( "claude-sonnet-4@20250514" )
545+ expect ( result . current . info ?. inputPrice ) . toBe ( 3.0 )
546+ expect ( result . current . info ?. outputPrice ) . toBe ( 15.0 )
547+ expect ( result . current . info ?. cacheWritesPrice ) . toBe ( 3.75 )
548+ expect ( result . current . info ?. cacheReadsPrice ) . toBe ( 0.3 )
549+ } )
550+
551+ it ( "applies global pricing for Sonnet 4 over 200k ([1m])" , ( ) => {
552+ const apiConfiguration : ProviderSettings = {
553+ apiProvider : "vertex" ,
554+ apiModelId : "claude-sonnet-4@20250514[1m]" ,
555+ vertexRegion : "global" ,
556+ }
557+
558+ const wrapper = createWrapper ( )
559+ const { result } = renderHook ( ( ) => useSelectedModel ( apiConfiguration ) , { wrapper } )
560+
561+ expect ( result . current . provider ) . toBe ( "vertex" )
562+ expect ( result . current . id ) . toBe ( "claude-sonnet-4@20250514[1m]" )
563+ expect ( result . current . info ?. inputPrice ) . toBe ( 6.0 )
564+ expect ( result . current . info ?. outputPrice ) . toBe ( 22.5 )
565+ expect ( result . current . info ?. cacheWritesPrice ) . toBe ( 7.5 )
566+ expect ( result . current . info ?. cacheReadsPrice ) . toBe ( 0.6 )
567+ } )
568+
569+ it ( "applies regional pricing for Sonnet 4.5 under 200k in us-east5" , ( ) => {
570+ const apiConfiguration : ProviderSettings = {
571+ apiProvider : "vertex" ,
572+ apiModelId : "claude-sonnet-4-5@20250929" ,
573+ vertexRegion : "us-east5" ,
574+ }
575+
576+ const wrapper = createWrapper ( )
577+ const { result } = renderHook ( ( ) => useSelectedModel ( apiConfiguration ) , { wrapper } )
578+
579+ expect ( result . current . provider ) . toBe ( "vertex" )
580+ expect ( result . current . id ) . toBe ( "claude-sonnet-4-5@20250929" )
581+ expect ( result . current . info ?. inputPrice ) . toBe ( 3.3 )
582+ expect ( result . current . info ?. outputPrice ) . toBe ( 16.5 )
583+ expect ( result . current . info ?. cacheWritesPrice ) . toBe ( 4.13 )
584+ expect ( result . current . info ?. cacheReadsPrice ) . toBe ( 0.33 )
585+ } )
586+
587+ it ( "applies regional pricing for Sonnet 4.5 over 200k ([1m]) in us-east5" , ( ) => {
588+ const apiConfiguration : ProviderSettings = {
589+ apiProvider : "vertex" ,
590+ apiModelId : "claude-sonnet-4-5@20250929[1m]" ,
591+ vertexRegion : "us-east5" ,
592+ }
593+
594+ const wrapper = createWrapper ( )
595+ const { result } = renderHook ( ( ) => useSelectedModel ( apiConfiguration ) , { wrapper } )
596+
597+ expect ( result . current . provider ) . toBe ( "vertex" )
598+ expect ( result . current . id ) . toBe ( "claude-sonnet-4-5@20250929[1m]" )
599+ expect ( result . current . info ?. inputPrice ) . toBe ( 6.6 )
600+ expect ( result . current . info ?. outputPrice ) . toBe ( 24.75 )
601+ expect ( result . current . info ?. cacheWritesPrice ) . toBe ( 8.25 )
602+ expect ( result . current . info ?. cacheReadsPrice ) . toBe ( 0.66 )
603+ } )
604+
605+ it ( "applies global pricing for Sonnet 4.5 over 200k ([1m]) in non-regional areas (e.g., us-central1)" , ( ) => {
606+ const apiConfiguration : ProviderSettings = {
607+ apiProvider : "vertex" ,
608+ apiModelId : "claude-sonnet-4-5@20250929[1m]" ,
609+ vertexRegion : "us-central1" , // treated as global pricing per rules
610+ }
611+
612+ const wrapper = createWrapper ( )
613+ const { result } = renderHook ( ( ) => useSelectedModel ( apiConfiguration ) , { wrapper } )
614+
615+ expect ( result . current . provider ) . toBe ( "vertex" )
616+ expect ( result . current . id ) . toBe ( "claude-sonnet-4-5@20250929[1m]" )
617+ expect ( result . current . info ?. inputPrice ) . toBe ( 6.0 )
618+ expect ( result . current . info ?. outputPrice ) . toBe ( 22.5 )
619+ expect ( result . current . info ?. cacheWritesPrice ) . toBe ( 7.5 )
620+ expect ( result . current . info ?. cacheReadsPrice ) . toBe ( 0.6 )
621+ } )
622+ } )
0 commit comments