Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/resources/responses/responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
*/
Expand Down
43 changes: 43 additions & 0 deletions tests/typing/response-partial-image-event.test.ts
Original file line number Diff line number Diff line change
@@ -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');
});
});