@@ -375,4 +375,70 @@ describe("openai codex provider", () => {
375375 name : "gpt-5.4" ,
376376 } ) ;
377377 } ) ;
378+
379+ it ( "defaults missing codex api metadata to openai-codex-responses" , ( ) => {
380+ const provider = buildOpenAICodexProviderPlugin ( ) ;
381+
382+ const model = provider . normalizeResolvedModel ?.( {
383+ provider : "openai-codex" ,
384+ model : {
385+ id : "gpt-5.4" ,
386+ name : "gpt-5.4" ,
387+ provider : "openai-codex" ,
388+ baseUrl : "https://chatgpt.com/backend-api" ,
389+ reasoning : true ,
390+ input : [ "text" , "image" ] ,
391+ cost : { input : 0 , output : 0 , cacheRead : 0 , cacheWrite : 0 } ,
392+ contextWindow : 1_050_000 ,
393+ contextTokens : 272_000 ,
394+ maxTokens : 128_000 ,
395+ } ,
396+ } as never ) ;
397+
398+ expect ( model ) . toMatchObject ( {
399+ api : "openai-codex-responses" ,
400+ baseUrl : "https://chatgpt.com/backend-api" ,
401+ } ) ;
402+ } ) ;
403+
404+ it ( "normalizes stale /backend-api/v1 codex metadata to the canonical base url" , ( ) => {
405+ const provider = buildOpenAICodexProviderPlugin ( ) ;
406+
407+ const model = provider . normalizeResolvedModel ?.( {
408+ provider : "openai-codex" ,
409+ model : {
410+ id : "gpt-5.4" ,
411+ name : "gpt-5.4" ,
412+ provider : "openai-codex" ,
413+ api : "openai-codex-responses" ,
414+ baseUrl : "https://chatgpt.com/backend-api/v1" ,
415+ reasoning : true ,
416+ input : [ "text" , "image" ] ,
417+ cost : { input : 0 , output : 0 , cacheRead : 0 , cacheWrite : 0 } ,
418+ contextWindow : 1_050_000 ,
419+ contextTokens : 272_000 ,
420+ maxTokens : 128_000 ,
421+ } ,
422+ } as never ) ;
423+
424+ expect ( model ) . toMatchObject ( {
425+ api : "openai-codex-responses" ,
426+ baseUrl : "https://chatgpt.com/backend-api" ,
427+ } ) ;
428+ } ) ;
429+
430+ it ( "normalizes transport metadata for stale /backend-api/v1 codex routes" , ( ) => {
431+ const provider = buildOpenAICodexProviderPlugin ( ) ;
432+
433+ expect (
434+ provider . normalizeTransport ?.( {
435+ provider : "openai-codex" ,
436+ api : "openai-codex-responses" ,
437+ baseUrl : "https://chatgpt.com/backend-api/v1" ,
438+ } as never ) ,
439+ ) . toEqual ( {
440+ api : "openai-codex-responses" ,
441+ baseUrl : "https://chatgpt.com/backend-api" ,
442+ } ) ;
443+ } ) ;
378444} ) ;
0 commit comments