@@ -29,6 +29,14 @@ import { createOpenaiCompatible as createGitHubCopilotOpenAICompatible } from ".
2929export namespace Provider {
3030 const log = Log . create ( { service : "provider" } )
3131
32+ function isGpt5OrLater ( modelID : string ) : boolean {
33+ const match = / ^ g p t - ( \d + ) / . exec ( modelID )
34+ if ( ! match ) {
35+ return false
36+ }
37+ return Number ( match [ 1 ] ) >= 5
38+ }
39+
3240 const BUNDLED_PROVIDERS : Record < string , ( options : any ) => SDK > = {
3341 "@ai-sdk/amazon-bedrock" : createAmazonBedrock ,
3442 "@ai-sdk/anthropic" : createAnthropic ,
@@ -91,25 +99,39 @@ export namespace Provider {
9199 options : { } ,
92100 }
93101 } ,
94- "github-copilot" : async ( ) => {
102+ "github-copilot" : async ( input ) => {
95103 return {
96104 autoload : false ,
97105 async getModel ( sdk : any , modelID : string , _options ?: Record < string , any > ) {
106+ // GitHub Copilot can optionally route supported models through the Responses API.
107+ // This enables settings like reasoningEffort/reasoningSummary for GPT-5+ models.
108+ const useResponsesApi = Boolean ( input . options ?. useResponsesApi )
109+
98110 if ( modelID . includes ( "codex" ) ) {
99111 return sdk . responses ( modelID )
100112 }
113+
114+ if ( useResponsesApi && isGpt5OrLater ( modelID ) ) {
115+ return sdk . responses ( modelID )
116+ }
101117 return sdk . chat ( modelID )
102118 } ,
103119 options : { } ,
104120 }
105121 } ,
106- "github-copilot-enterprise" : async ( ) => {
122+ "github-copilot-enterprise" : async ( input ) => {
107123 return {
108124 autoload : false ,
109125 async getModel ( sdk : any , modelID : string , _options ?: Record < string , any > ) {
126+ const useResponsesApi = Boolean ( input . options ?. useResponsesApi )
127+
110128 if ( modelID . includes ( "codex" ) ) {
111129 return sdk . responses ( modelID )
112130 }
131+
132+ if ( useResponsesApi && isGpt5OrLater ( modelID ) ) {
133+ return sdk . responses ( modelID )
134+ }
113135 return sdk . chat ( modelID )
114136 } ,
115137 options : { } ,
0 commit comments