Skip to content

Commit d2f2331

Browse files
authored
Merge pull request #19 from stainless-sdks/blaine/fix-image-types
chore: Fix Type resolution on Image API via param discrimination
2 parents 568c387 + 1f56b8d commit d2f2331

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/resources/images.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@ export class Images extends APIResource {
1616
* });
1717
* ```
1818
*/
19-
create(body: ImageCreateParams, options?: RequestOptions): APIPromise<ImageFile> {
19+
create<Body extends ImageCreateParams>(
20+
body: Body,
21+
options?: RequestOptions,
22+
): APIPromise<
23+
Omit<ImageFile, 'data'> & {
24+
data: Body['response_format'] extends 'base64' ? ImageDataB64[] : ImageDataURL[];
25+
}
26+
> {
2027
return this._client.post('/images/generations', { body, ...options });
2128
}
2229
}

0 commit comments

Comments
 (0)