@@ -21,6 +21,8 @@ describe("provider package entrypoints", () => {
2121 import ( "@opencode-ai/ai/providers/google-vertex/chat" ) ,
2222 import ( "@opencode-ai/ai/providers/google-vertex/responses" ) ,
2323 import ( "@opencode-ai/ai/providers/google-vertex/messages" ) ,
24+ import ( "@opencode-ai/ai/providers/openrouter" ) ,
25+ import ( "@opencode-ai/ai/providers/xai" ) ,
2426 ] )
2527
2628 for ( const module of modules ) expect ( module . model ) . toBeFunction ( )
@@ -29,6 +31,35 @@ describe("provider package entrypoints", () => {
2931 expect ( modules [ 12 ] . model ) . toBe ( modules [ 13 ] . model )
3032 } )
3133
34+ test ( "maps OpenRouter and xAI package settings onto executable models" , async ( ) => {
35+ const OpenRouter = await import ( "@opencode-ai/ai/providers/openrouter" )
36+ const XAI = await import ( "@opencode-ai/ai/providers/xai" )
37+ const settings = {
38+ apiKey : "fixture" ,
39+ baseURL : "https://provider.example.test/v1" ,
40+ headers : { "x-application" : "opencode" } ,
41+ body : { service_tier : "priority" } ,
42+ limits : { context : 200_000 , output : 64_000 } ,
43+ }
44+ const openrouter = OpenRouter . model ( "anthropic/claude-sonnet-4" , {
45+ ...settings ,
46+ providerOptions : { openrouter : { usage : true } } ,
47+ } )
48+ const xai = XAI . model ( "grok-4" , {
49+ ...settings ,
50+ providerOptions : { openai : { reasoningEffort : "high" } } ,
51+ } )
52+
53+ for ( const selected of [ openrouter , xai ] ) {
54+ expect ( selected . route . endpoint . baseURL ) . toBe ( settings . baseURL )
55+ expect ( selected . route . defaults . headers ) . toEqual ( settings . headers )
56+ expect ( selected . route . defaults . http ?. body ) . toEqual ( settings . body )
57+ expect ( selected . route . defaults . limits ) . toEqual ( settings . limits )
58+ }
59+ expect ( openrouter . route . defaults . providerOptions ) . toEqual ( { openrouter : { usage : true } } )
60+ expect ( xai . route . defaults . providerOptions ) . toEqual ( { openai : { reasoningEffort : "high" , store : false } } )
61+ } )
62+
3263 test ( "maps package settings onto the executable model" , ( ) => {
3364 const selected = model ( "gpt-5" , {
3465 apiKey : "fixture" ,
0 commit comments