Skip to content

Commit 2311a15

Browse files
fix: send correct Accept header for certain endpoints (#1257)
1 parent d0afb9e commit 2311a15

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/resources/audio/speech.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ export class Speech extends APIResource {
99
* Generates audio from the input text.
1010
*/
1111
create(body: SpeechCreateParams, options?: Core.RequestOptions): Core.APIPromise<Response> {
12-
return this._client.post('/audio/speech', { body, ...options, __binaryResponse: true });
12+
return this._client.post('/audio/speech', {
13+
body,
14+
...options,
15+
headers: { Accept: 'application/octet-stream', ...options?.headers },
16+
__binaryResponse: true,
17+
});
1318
}
1419
}
1520

src/resources/files.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ export class Files extends APIResource {
6767
* Returns the contents of the specified file.
6868
*/
6969
content(fileId: string, options?: Core.RequestOptions): Core.APIPromise<Response> {
70-
return this._client.get(`/files/${fileId}/content`, { ...options, __binaryResponse: true });
70+
return this._client.get(`/files/${fileId}/content`, {
71+
...options,
72+
headers: { Accept: 'application/binary', ...options?.headers },
73+
__binaryResponse: true,
74+
});
7175
}
7276

7377
/**
@@ -76,10 +80,7 @@ export class Files extends APIResource {
7680
* @deprecated The `.content()` method should be used instead
7781
*/
7882
retrieveContent(fileId: string, options?: Core.RequestOptions): Core.APIPromise<string> {
79-
return this._client.get(`/files/${fileId}/content`, {
80-
...options,
81-
headers: { Accept: 'application/json', ...options?.headers },
82-
});
83+
return this._client.get(`/files/${fileId}/content`, options);
8384
}
8485
}
8586

0 commit comments

Comments
 (0)