@@ -383,7 +383,41 @@ class OpenAITestsDecoder: XCTestCase {
383383 let decoded = try JSONDecoder ( ) . decode ( Components . Schemas. Reasoning. self, from: data)
384384 XCTAssertEqual ( decoded. effort, . minimal)
385385 }
386-
386+
387+ func testVerbosityDecoding( ) throws {
388+ // Test decoding "low"
389+ let jsonLow = """
390+ { " format " : { " type " : " text " }, " verbosity " : " low " }
391+ """
392+ let dataLow = jsonLow. data ( using: . utf8) !
393+ let decodedLow = try JSONDecoder ( ) . decode ( CreateModelResponseQuery . TextResponseConfigurationOptions. self, from: dataLow)
394+ XCTAssertEqual ( decodedLow. verbosity, . low)
395+
396+ // Test decoding "medium"
397+ let jsonMedium = """
398+ { " format " : { " type " : " text " }, " verbosity " : " medium " }
399+ """
400+ let dataMedium = jsonMedium. data ( using: . utf8) !
401+ let decodedMedium = try JSONDecoder ( ) . decode ( CreateModelResponseQuery . TextResponseConfigurationOptions. self, from: dataMedium)
402+ XCTAssertEqual ( decodedMedium. verbosity, . medium)
403+
404+ // Test decoding "high"
405+ let jsonHigh = """
406+ { " format " : { " type " : " text " }, " verbosity " : " high " }
407+ """
408+ let dataHigh = jsonHigh. data ( using: . utf8) !
409+ let decodedHigh = try JSONDecoder ( ) . decode ( CreateModelResponseQuery . TextResponseConfigurationOptions. self, from: dataHigh)
410+ XCTAssertEqual ( decodedHigh. verbosity, . high)
411+
412+ // Test decoding without verbosity (should be nil)
413+ let jsonNil = """
414+ { " format " : { " type " : " text " } }
415+ """
416+ let dataNil = jsonNil. data ( using: . utf8) !
417+ let decodedNil = try JSONDecoder ( ) . decode ( CreateModelResponseQuery . TextResponseConfigurationOptions. self, from: dataNil)
418+ XCTAssertNil ( decodedNil. verbosity)
419+ }
420+
387421 func testEmbeddings( ) async throws {
388422 let data = """
389423 {
@@ -812,7 +846,18 @@ class OpenAITestsDecoder: XCTestCase {
812846 let data = try JSONEncoder ( ) . encode ( query)
813847 try testEncodedCreateResponseQueryWithStructuredOutput ( data)
814848 }
815-
849+
850+ func testCreateResponseQueryWithVerbosity( ) throws {
851+ let query = CreateModelResponseQuery (
852+ input: . textInput( " Return a low verbosity response. " ) ,
853+ model: . gpt5,
854+ text: . init( format: . text, verbosity: . low)
855+ )
856+
857+ let data = try JSONEncoder ( ) . encode ( query)
858+ try testEncodedCreateResponseQueryWithVerbosity ( data)
859+ }
860+
816861 private func testEncodedChatQueryWithStructuredOutput( _ data: Data ) throws {
817862 let dict = try XCTUnwrap ( JSONSerialization . jsonObject ( with: data) as? [ String : Any ] )
818863 XCTAssertEqual ( try XCTUnwrap ( dict [ " model " ] as? String ) , " gpt-4o " )
@@ -854,4 +899,16 @@ class OpenAITestsDecoder: XCTestCase {
854899 XCTAssertEqual ( titleSchema. count, 1 )
855900 XCTAssertEqual ( try XCTUnwrap ( titleSchema [ " type " ] as? String ) , " string " )
856901 }
902+
903+ private func testEncodedCreateResponseQueryWithVerbosity( _ data: Data ) throws {
904+ let dict = try XCTUnwrap ( JSONSerialization . jsonObject ( with: data) as? [ String : Any ] )
905+ XCTAssertEqual ( try XCTUnwrap ( dict [ " model " ] as? String ) , " gpt-5 " )
906+
907+ let textResponseConfigurationOptions = try XCTUnwrap ( dict [ " text " ] as? [ String : Any ] )
908+ let outputFormat = try XCTUnwrap ( textResponseConfigurationOptions [ " format " ] as? [ String : Any ] )
909+ let outputVerbosity = try XCTUnwrap ( textResponseConfigurationOptions [ " verbosity " ] as? String )
910+
911+ XCTAssertEqual ( try XCTUnwrap ( outputFormat [ " type " ] as? String ) , " text " )
912+ XCTAssertNotNil ( CreateModelResponseQuery . TextResponseConfigurationOptions. Verbosity ( rawValue: outputVerbosity) )
913+ }
857914}
0 commit comments