@@ -493,6 +493,12 @@ describe("buildOpenAIProvider", () => {
493493 data : [
494494 { id : "gpt-5.6" , object : "model" } ,
495495 { id : "gpt-5.5" , object : "model" } ,
496+ { id : "chat-latest" , object : "model" } ,
497+ { id : "gpt-5.4" , object : "model" } ,
498+ { id : "gpt-5.4-pro" , object : "model" } ,
499+ { id : "gpt-5.4-mini" , object : "model" } ,
500+ { id : "gpt-5.4-nano" , object : "model" } ,
501+ { id : "gpt-5.3-codex-spark" , object : "model" } ,
496502 { id : "not-in-manifest" , object : "model" } ,
497503 ] ,
498504 } ) ,
@@ -508,6 +514,47 @@ describe("buildOpenAIProvider", () => {
508514 expect ( provider . apiKey ) . toBe ( "sk-openai" ) ;
509515 expect ( provider . models . map ( ( model ) => model . id ) ) . toContain ( "gpt-5.6" ) ;
510516 expect ( provider . models . map ( ( model ) => model . id ) ) . toContain ( "gpt-5.5" ) ;
517+ expect ( provider . models . map ( ( model ) => model . id ) ) . toEqual (
518+ expect . arrayContaining ( [
519+ "chat-latest" ,
520+ "gpt-5.4" ,
521+ "gpt-5.4-pro" ,
522+ "gpt-5.4-mini" ,
523+ "gpt-5.4-nano" ,
524+ ] ) ,
525+ ) ;
526+ expect ( provider . models . find ( ( model ) => model . id === "chat-latest" ) ) . toMatchObject ( {
527+ api : "openai-responses" ,
528+ baseUrl : "https://api.openai.com/v1" ,
529+ contextWindow : 400_000 ,
530+ maxTokens : 128_000 ,
531+ reasoning : false ,
532+ cost : { input : 5 , output : 30 , cacheRead : 0.5 , cacheWrite : 0 } ,
533+ } ) ;
534+ expect ( provider . models . find ( ( model ) => model . id === "gpt-5.4-pro" ) ) . toMatchObject ( {
535+ api : "openai-responses" ,
536+ baseUrl : "https://api.openai.com/v1" ,
537+ contextWindow : 1_050_000 ,
538+ maxTokens : 128_000 ,
539+ reasoning : true ,
540+ input : [ "text" ] ,
541+ cost : { input : 30 , output : 180 , cacheRead : 0 , cacheWrite : 0 } ,
542+ } ) ;
543+ expect ( provider . models . find ( ( model ) => model . id === "gpt-5.4-mini" ) ) . toMatchObject ( {
544+ api : "openai-responses" ,
545+ baseUrl : "https://api.openai.com/v1" ,
546+ contextWindow : 400_000 ,
547+ maxTokens : 128_000 ,
548+ cost : { input : 0.75 , output : 4.5 , cacheRead : 0.075 , cacheWrite : 0 } ,
549+ } ) ;
550+ expect ( provider . models . find ( ( model ) => model . id === "gpt-5.4-nano" ) ) . toMatchObject ( {
551+ api : "openai-responses" ,
552+ baseUrl : "https://api.openai.com/v1" ,
553+ contextWindow : 400_000 ,
554+ maxTokens : 128_000 ,
555+ cost : { input : 0.2 , output : 1.25 , cacheRead : 0.02 , cacheWrite : 0 } ,
556+ } ) ;
557+ expect ( provider . models . map ( ( model ) => model . id ) ) . not . toContain ( "gpt-5.3-codex-spark" ) ;
511558 expect ( provider . models . map ( ( model ) => model . id ) ) . not . toContain ( "not-in-manifest" ) ;
512559 const fetchParams = vi . mocked ( fetchGuard ) . mock . calls [ 0 ] ?. [ 0 ] ;
513560 expect ( fetchParams ?. url ) . toBe ( "https://api.openai.com/v1/models" ) ;
@@ -521,6 +568,38 @@ describe("buildOpenAIProvider", () => {
521568 expect ( release ) . toHaveBeenCalledOnce ( ) ;
522569 } ) ;
523570
571+ it ( "does not surface platform models omitted by the account's live catalog" , async ( ) => {
572+ const fetchGuard : LiveModelCatalogFetchGuard = vi . fn ( async ( ) => ( {
573+ response : Response . json ( { data : [ { id : "gpt-5.5" , object : "model" } ] } ) ,
574+ finalUrl : "https://api.openai.com/v1/models" ,
575+ release : async ( ) => undefined ,
576+ } ) ) ;
577+
578+ const provider = await buildOpenAILiveProviderConfig ( {
579+ apiKey : "sk-openai" ,
580+ fetchGuard,
581+ } ) ;
582+
583+ expect ( provider . models . map ( ( model ) => model . id ) ) . toEqual ( [ "gpt-5.5" ] ) ;
584+ } ) ;
585+
586+ it ( "keeps only manifest fallback models when OpenAI discovery is unavailable" , async ( ) => {
587+ const fetchGuard : LiveModelCatalogFetchGuard = vi . fn ( async ( ) => ( {
588+ response : new Response ( "temporarily unavailable" , { status : 503 } ) ,
589+ finalUrl : "https://api.openai.com/v1/models" ,
590+ release : async ( ) => undefined ,
591+ } ) ) ;
592+
593+ const provider = await buildOpenAILiveProviderConfig ( {
594+ apiKey : "sk-openai" ,
595+ fetchGuard,
596+ } ) ;
597+
598+ expect ( provider . models . map ( ( model ) => model . id ) ) . toEqual (
599+ manifest . modelCatalog . providers . openai . models . map ( ( model ) => model . id ) ,
600+ ) ;
601+ } ) ;
602+
524603 it ( "skips OpenAI live discovery for custom OpenAI-compatible base URLs" , async ( ) => {
525604 const customBaseUrl = "https://example-proxy.invalid/v1" ;
526605 const fetchGuard : LiveModelCatalogFetchGuard = vi . fn ( async ( ) => {
0 commit comments