@@ -30,7 +30,7 @@ The full API of this library can be found in [api.md](api.md).
30
30
``` js
31
31
import OpenAI from ' openai' ;
32
32
33
- const openai = new OpenAI ({
33
+ const client = new OpenAI ({
34
34
apiKey: process .env [' OPENAI_API_KEY' ], // This is the default and can be omitted
35
35
});
36
36
@@ -51,7 +51,7 @@ We provide support for streaming responses using Server Sent Events (SSE).
51
51
``` ts
52
52
import OpenAI from ' openai' ;
53
53
54
- const openai = new OpenAI ();
54
+ const client = new OpenAI ();
55
55
56
56
const stream = await openai .chat .completions .create ({
57
57
messages: [{ role: ' user' , content: ' Say this is a test' }],
@@ -74,7 +74,7 @@ This library includes TypeScript definitions for all request params and response
74
74
``` ts
75
75
import OpenAI from ' openai' ;
76
76
77
- const openai = new OpenAI ({
77
+ const client = new OpenAI ({
78
78
apiKey: process .env [' OPENAI_API_KEY' ], // This is the default and can be omitted
79
79
});
80
80
@@ -105,7 +105,7 @@ import fs from 'fs';
105
105
import fetch from ' node-fetch' ;
106
106
import OpenAI , { toFile } from ' openai' ;
107
107
108
- const openai = new OpenAI ();
108
+ const client = new OpenAI ();
109
109
110
110
// If you have access to Node `fs` we recommend using `fs.createReadStream()`:
111
111
await openai .files .create ({ file: fs .createReadStream (' input.jsonl' ), purpose: ' fine-tune' });
@@ -176,7 +176,7 @@ You can use the `maxRetries` option to configure or disable this:
176
176
<!-- prettier-ignore -->
177
177
``` js
178
178
// Configure the default for all requests:
179
- const openai = new OpenAI ({
179
+ const client = new OpenAI ({
180
180
maxRetries: 0 , // default is 2
181
181
});
182
182
@@ -193,7 +193,7 @@ Requests time out after 10 minutes by default. You can configure this with a `ti
193
193
<!-- prettier-ignore -->
194
194
``` ts
195
195
// Configure the default for all requests:
196
- const openai = new OpenAI ({
196
+ const client = new OpenAI ({
197
197
timeout: 20 * 1000 , // 20 seconds (default is 10 minutes)
198
198
});
199
199
@@ -248,7 +248,7 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi
248
248
249
249
<!-- prettier-ignore -->
250
250
``` ts
251
- const openai = new OpenAI ();
251
+ const client = new OpenAI ();
252
252
253
253
const response = await openai .chat .completions
254
254
.create ({ messages: [{ role: ' user' , content: ' Say this is a test' }], model: ' gpt-3.5-turbo' })
@@ -359,7 +359,7 @@ import http from 'http';
359
359
import { HttpsProxyAgent } from ' https-proxy-agent' ;
360
360
361
361
// Configure the default for all requests:
362
- const openai = new OpenAI ({
362
+ const client = new OpenAI ({
363
363
httpAgent: new HttpsProxyAgent (process .env .PROXY_URL ),
364
364
});
365
365
0 commit comments