Skip to content

Commit c246e91

Browse files
feat(api): Change the default max retries from 5 to 2
BREAKING CHANGE: The default max retries for api calls has changed from 5 to 2. This may result in more frequent non-200 responses.
1 parent 3476272 commit c246e91

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 41
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-f53d9282224f2c3943d83d014d64ba61271f3aedef59197cc4dae0102d2b365d.yml
33
openapi_spec_hash: a884fe7d04e9f64675e3943a962ebb65
4-
config_hash: 74799f281947721570d77d51e09f278e
4+
config_hash: 3c3a676f96a972da95e0e85618e64c76

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ Error codes are as follows:
165165

166166
### Retries
167167

168-
Certain errors will be automatically retried 5 times by default, with a short exponential backoff.
168+
Certain errors will be automatically retried 2 times by default, with a short exponential backoff.
169169
Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,
170170
429 Rate Limit, and >=500 Internal errors will all be retried by default.
171171

src/client.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export interface ClientOptions {
161161
* The maximum number of times that the client will retry a request in case of a
162162
* temporary failure, like a network error or a 5XX error from the server.
163163
*
164-
* @default 5
164+
* @default 2
165165
*/
166166
maxRetries?: number | undefined;
167167

@@ -222,7 +222,7 @@ export class Together {
222222
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
223223
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
224224
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
225-
* @param {number} [opts.maxRetries=5] - The maximum number of times the client will retry a request.
225+
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
226226
* @param {HeadersLike} opts.defaultHeaders - Default headers to include with every request to the API.
227227
* @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
228228
*/
@@ -254,7 +254,7 @@ export class Together {
254254
parseLogLevel(readEnv('TOGETHER_LOG'), "process.env['TOGETHER_LOG']", this) ??
255255
defaultLogLevel;
256256
this.fetchOptions = options.fetchOptions;
257-
this.maxRetries = options.maxRetries ?? 5;
257+
this.maxRetries = options.maxRetries ?? 2;
258258
this.fetch = options.fetch ?? Shims.getDefaultFetch();
259259
this.#encoder = Opts.FallbackEncoder;
260260

src/internal/request-options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export type RequestOptions = {
4141
* The maximum number of times that the client will retry a request in case of a
4242
* temporary failure, like a network error or a 5XX error from the server.
4343
*
44-
* @default 5
44+
* @default 2
4545
*/
4646
maxRetries?: number;
4747

tests/index.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,12 +339,12 @@ describe('instantiate client', () => {
339339
});
340340

341341
test('maxRetries option is correctly set', () => {
342-
const client = new Together({ maxRetries: 10, apiKey: 'My API Key' });
343-
expect(client.maxRetries).toEqual(10);
342+
const client = new Together({ maxRetries: 4, apiKey: 'My API Key' });
343+
expect(client.maxRetries).toEqual(4);
344344

345345
// default
346346
const client2 = new Together({ apiKey: 'My API Key' });
347-
expect(client2.maxRetries).toEqual(5);
347+
expect(client2.maxRetries).toEqual(2);
348348
});
349349

350350
describe('withOptions', () => {

0 commit comments

Comments
 (0)