You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+6-3Lines changed: 6 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,6 +30,7 @@ import OpenAI from 'https://deno.land/x/[email protected]/mod.ts';
30
30
31
31
The full API of this library can be found in [api.md file](api.md) along with many [code examples](https://github.com/openai/openai-node/tree/master/examples). The code below shows how to get started using the chat completions API.
32
32
33
+
<!-- prettier-ignore -->
33
34
```js
34
35
importOpenAIfrom'openai';
35
36
@@ -77,6 +78,7 @@ or call `stream.controller.abort()`.
77
78
78
79
This library includes TypeScript definitions for all request params and response fields. You may import and use them like so:
79
80
81
+
<!-- prettier-ignore -->
80
82
```ts
81
83
importOpenAIfrom'openai';
82
84
@@ -267,6 +269,7 @@ When the library is unable to connect to the API,
267
269
or if the API returns a non-success status code (i.e., 4xx or 5xx response),
268
270
a subclass of `APIError` will be thrown:
269
271
272
+
<!-- prettier-ignore -->
270
273
```ts
271
274
asyncfunction main() {
272
275
const fineTune =awaitopenai.fineTunes
@@ -388,6 +391,7 @@ The "raw" `Response` returned by `fetch()` can be accessed through the `.asRespo
388
391
389
392
You can also use the `.withResponse()` method to get the raw `Response` along with the parsed data.
390
393
394
+
<!-- prettier-ignore -->
391
395
```ts
392
396
const openai =newOpenAI();
393
397
@@ -412,12 +416,11 @@ If you would prefer to use a global, web-standards-compliant `fetch` function ev
412
416
(for example, if you are running Node with `--experimental-fetch` or using NextJS which polyfills with `undici`),
413
417
add the following import before your first import `from "OpenAI"`:
414
418
415
-
<!-- prettier-ignore -->
416
419
```ts
417
420
// Tell TypeScript and the package to use the global web fetch instead of node-fetch.
418
421
// Note, despite the name, this does not add any polyfills, but expects them to be provided if needed.
419
-
import"openai/shims/web";
420
-
importOpenAIfrom"openai";
422
+
import'openai/shims/web';
423
+
importOpenAIfrom'openai';
421
424
```
422
425
423
426
To do the inverse, add `import "openai/shims/node"` (which does import polyfills).
0 commit comments