@@ -802,15 +802,22 @@ export namespace ProviderTransform {
802802 return { }
803803 }
804804
805+ // Maps model ID prefix to provider slug used in providerOptions.
806+ // Example: "amazon/nova-2-lite" → "bedrock"
807+ const SLUG_OVERRIDES : Record < string , string > = {
808+ amazon : "bedrock" ,
809+ }
810+
805811 export function providerOptions ( model : Provider . Model , options : { [ x : string ] : any } ) {
806812 if ( model . api . npm === "@ai-sdk/gateway" ) {
807813 // Gateway providerOptions are split across two namespaces:
808- // - `gateway`: gateway-native routing/caching controls
814+ // - `gateway`: gateway-native routing/caching controls (order, only, byok, etc.)
809815 // - `<upstream slug>`: provider-specific model options (anthropic/openai/...)
810816 // We keep `gateway` as-is and route every other top-level option under the
811- // model-derived upstream slug so variants/options can stay flat internally .
817+ // model-derived upstream slug.
812818 const i = model . api . id . indexOf ( "/" )
813- const slug = i > 0 ? model . api . id . slice ( 0 , i ) : undefined
819+ const rawSlug = i > 0 ? model . api . id . slice ( 0 , i ) : undefined
820+ const slug = rawSlug ? ( SLUG_OVERRIDES [ rawSlug ] ?? rawSlug ) : undefined
814821 const gateway = options . gateway
815822 const rest = Object . fromEntries ( Object . entries ( options ) . filter ( ( [ k ] ) => k !== "gateway" ) )
816823 const has = Object . keys ( rest ) . length > 0
@@ -820,6 +827,7 @@ export namespace ProviderTransform {
820827
821828 if ( has ) {
822829 if ( slug ) {
830+ // Route model-specific options under the provider slug
823831 result [ slug ] = rest
824832 } else if ( gateway && typeof gateway === "object" && ! Array . isArray ( gateway ) ) {
825833 result . gateway = { ...gateway , ...rest }
0 commit comments