Skip to content

Commit 6070d96

Browse files
fix: send correct Accept header for certain endpoints (#1257)
1 parent 66c9715 commit 6070d96

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

Diff for: src/resources/audio/speech.ts

+6-1
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

Diff for: src/resources/files.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ export class Files extends APIResource {
6969
* Returns the contents of the specified file.
7070
*/
7171
content(fileId: string, options?: Core.RequestOptions): Core.APIPromise<Response> {
72-
return this._client.get(`/files/${fileId}/content`, { ...options, __binaryResponse: true });
72+
return this._client.get(`/files/${fileId}/content`, {
73+
...options,
74+
headers: { Accept: 'application/binary', ...options?.headers },
75+
__binaryResponse: true,
76+
});
7377
}
7478

7579
/**
@@ -78,10 +82,7 @@ export class Files extends APIResource {
7882
* @deprecated The `.content()` method should be used instead
7983
*/
8084
retrieveContent(fileId: string, options?: Core.RequestOptions): Core.APIPromise<string> {
81-
return this._client.get(`/files/${fileId}/content`, {
82-
...options,
83-
headers: { Accept: 'application/json', ...options?.headers },
84-
});
85+
return this._client.get(`/files/${fileId}/content`, options);
8586
}
8687

8788
/**

0 commit comments

Comments
 (0)