Skip to content

Commit

Permalink
Fix ERR_FR_MAX_BODY_LENGTH_EXCEEDED issue by setting default maxBodyL…
Browse files Browse the repository at this point in the history
…ength

This PR addresses the issue [#167](#167), where a `ERR_FR_MAX_BODY_LENGTH_EXCEEDED` error is thrown when the `createTranscription` function is used with an audio file larger than 10 MB but smaller than 25 MB.

This is because the library uses `axios` which defaults to a 10 MB body limit.

The issue is resolved by setting a default `maxBodyLength` of 25 MB if it is not already set. This ensures that the limit aligns with OpenAI's maximum file size limit.
  • Loading branch information
aelesia committed Jul 5, 2023
1 parent dc821be commit f1c7f13
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ export class Configuration {
'Authorization': `Bearer ${this.apiKey}`,
...this.baseOptions.headers,
}
if (!this.baseOptions.maxBodyLength) {
this.baseOptions.maxBodyLength = 25 * 1024 * 1024; // 25MB
}
if (this.organization) {
this.baseOptions.headers['OpenAI-Organization'] = this.organization;
}
Expand Down
3 changes: 3 additions & 0 deletions dist/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class Configuration {
this.baseOptions = {};
}
this.baseOptions.headers = Object.assign({ 'User-Agent': `OpenAI/NodeJS/${packageJson.version}`, 'Authorization': `Bearer ${this.apiKey}` }, this.baseOptions.headers);
if (!this.baseOptions.maxBodyLength) {
this.baseOptions.maxBodyLength = 25 * 1024 * 1024; // 25MB
}
if (this.organization) {
this.baseOptions.headers['OpenAI-Organization'] = this.organization;
}
Expand Down

0 comments on commit f1c7f13

Please sign in to comment.