Skip to content

Commit 37de535

Browse files
committedAug 15, 2023
v4.0.0-beta.12
1 parent 68ac889 commit 37de535

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed
 

‎README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,13 @@ await openai.chat.completions.create({ messages: [{ role: 'user', content: 'How
187187

188188
### Timeouts
189189

190-
Requests time out after 60 seconds by default. You can configure this with a `timeout` option:
190+
Requests time out after 10 minutes by default. You can configure this with a `timeout` option:
191191

192192
<!-- prettier-ignore -->
193193
```ts
194194
// Configure the default for all requests:
195195
const openai = new OpenAI({
196-
timeout: 20 * 1000, // 20 seconds (default is 60s)
196+
timeout: 20 * 1000, // 20 seconds (default is 10 minutes)
197197
});
198198

199199
// Override per-request:

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openai",
3-
"version": "4.0.0-beta.11",
3+
"version": "4.0.0-beta.12",
44
"description": "Client library for the OpenAI API",
55
"author": "OpenAI <support@openai.com>",
66
"types": "dist/index.d.ts",

‎src/core.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export abstract class APIClient {
135135
constructor({
136136
baseURL,
137137
maxRetries,
138-
timeout = 60 * 1000, // 60s
138+
timeout = 600000, // 10 minutes
139139
httpAgent,
140140
fetch: overridenFetch,
141141
}: {
@@ -254,7 +254,10 @@ export abstract class APIClient {
254254
const timeout = options.timeout ?? this.timeout;
255255
const httpAgent = options.httpAgent ?? this.httpAgent ?? getDefaultAgent(url);
256256
const minAgentTimeout = timeout + 1000;
257-
if ((httpAgent as any)?.options && minAgentTimeout > ((httpAgent as any).options.timeout ?? 0)) {
257+
if (
258+
typeof (httpAgent as any)?.options?.timeout === 'number' &&
259+
minAgentTimeout > ((httpAgent as any).options.timeout ?? 0)
260+
) {
258261
// Allow any given request to bump our agent active socket timeout.
259262
// This may seem strange, but leaking active sockets should be rare and not particularly problematic,
260263
// and without mutating agent we would need to create more of them.

‎src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export class OpenAI extends Core.APIClient {
9090
}: ClientOptions = {}) {
9191
if (apiKey === undefined) {
9292
throw new Error(
93-
'The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: undefined }).',
93+
"The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'my apiKey' }).",
9494
);
9595
}
9696

@@ -109,7 +109,7 @@ export class OpenAI extends Core.APIClient {
109109

110110
super({
111111
baseURL: options.baseURL!,
112-
timeout: options.timeout ?? 600000,
112+
timeout: options.timeout ?? 600000 /* 10 minutes */,
113113
httpAgent: options.httpAgent,
114114
maxRetries: options.maxRetries,
115115
fetch: options.fetch,

‎src/version.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const VERSION = '4.0.0-beta.11';
1+
export const VERSION = '4.0.0-beta.12';

0 commit comments

Comments
 (0)
Please sign in to comment.