From 11781feb421a8222127ac2cf3423d561980722cb Mon Sep 17 00:00:00 2001 From: tawseefnabi Date: Wed, 20 Aug 2025 08:44:22 +0530 Subject: [PATCH] responses: add size/quality/background/output_format to partial image event typing --- src/resources/responses/responses.ts | 22 ++++++++++ .../response-partial-image-event.test.ts | 43 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 tests/typing/response-partial-image-event.test.ts diff --git a/src/resources/responses/responses.ts b/src/resources/responses/responses.ts index c921f253d..5f40a6040 100644 --- a/src/resources/responses/responses.ts +++ b/src/resources/responses/responses.ts @@ -2066,6 +2066,28 @@ export interface ResponseImageGenCallPartialImageEvent { */ sequence_number: number; + /** + * The size of the generated image. One of `1024x1024`, `1024x1536`, `1536x1024`, + * or `auto`. + */ + size?: '1024x1024' | '1024x1536' | '1536x1024' | 'auto'; + + /** + * The quality of the generated image. One of `low`, `medium`, `high`, or `auto`. + */ + quality?: 'low' | 'medium' | 'high' | 'auto'; + + /** + * Background type for the generated image. One of `transparent`, `opaque`, or + * `auto`. + */ + background?: 'transparent' | 'opaque' | 'auto'; + + /** + * The output format of the generated image. One of `png`, `webp`, or `jpeg`. + */ + output_format?: 'png' | 'webp' | 'jpeg'; + /** * The type of the event. Always 'response.image_generation_call.partial_image'. */ diff --git a/tests/typing/response-partial-image-event.test.ts b/tests/typing/response-partial-image-event.test.ts new file mode 100644 index 000000000..ee4b01a28 --- /dev/null +++ b/tests/typing/response-partial-image-event.test.ts @@ -0,0 +1,43 @@ +import type { ResponseImageGenCallPartialImageEvent } from 'openai/resources/responses/responses'; + +// This test is intentionally simple: it verifies the SDK exposes the right +// fields on the streaming partial image event by constructing a value that +// matches the observed payload shape. If this ever stops compiling, the +// typings regressed. + +describe('ResponseImageGenCallPartialImageEvent typing', () => { + test('accepts full payload with image options', () => { + const evt: ResponseImageGenCallPartialImageEvent = { + type: 'response.image_generation_call.partial_image', + sequence_number: 7, + output_index: 0, + item_id: 'ig_123', + partial_image_index: 2, + partial_image_b64: '...base64...', + size: '1024x1536', + quality: 'high', + background: 'opaque', + output_format: 'png', + }; + + expect(evt).toHaveProperty('type', 'response.image_generation_call.partial_image'); + expect(evt).toHaveProperty('size', '1024x1536'); + expect(evt).toHaveProperty('quality', 'high'); + expect(evt).toHaveProperty('background', 'opaque'); + expect(evt).toHaveProperty('output_format', 'png'); + }); + + test('optional fields can be omitted', () => { + const evt: ResponseImageGenCallPartialImageEvent = { + type: 'response.image_generation_call.partial_image', + sequence_number: 1, + output_index: 0, + item_id: 'ig_omit', + partial_image_index: 0, + partial_image_b64: 'AAA', + // size, quality, background, output_format are optional + }; + + expect(evt.item_id).toBe('ig_omit'); + }); +});