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
This library provides convenient access to the OpenAI REST API from TypeScript or JavaScript.
5
+
This library provides convenient access to the OpenAI REST API from server-side TypeScript or JavaScript.
6
6
7
-
It is generated from our [OpenAPI specification](https://github.com/openai/openai-openapi) with [Stainless](https://stainlessapi.com/).
8
-
9
-
To learn how to use the OpenAI API, check out our [API Reference](https://platform.openai.com/docs/api-reference) and [Documentation](https://platform.openai.com/docs).
7
+
The REST API documentation can be found [on platform.openai.com](https://platform.openai.com/docs). The full API of this library can be found in [api.md](api.md).
10
8
11
9
## Installation
12
10
@@ -26,7 +24,7 @@ import OpenAI from 'https://deno.land/x/openai@v4.47.1/mod.ts';
26
24
27
25
## Usage
28
26
29
-
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.
27
+
The full API of this library can be found in [api.md](api.md).
messages: [{ role: 'user', content: 'Say this is a test' }],
58
+
model: 'gpt-3.5-turbo',
59
+
stream: true,
60
+
});
61
+
forawait (const chatCompletionChunk ofstream) {
62
+
console.log(chatCompletionChunk);
67
63
}
68
-
69
-
main();
70
64
```
71
65
72
66
If you need to cancel a stream, you can `break` from the loop
@@ -97,196 +91,6 @@ main();
97
91
98
92
Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
99
93
100
-
> [!IMPORTANT]
101
-
> Previous versions of this SDK used a `Configuration` class. See the [v3 to v4 migration guide](https://github.com/openai/openai-node/discussions/217).
102
-
103
-
### Polling Helpers
104
-
105
-
When interacting with the API some actions such as starting a Run and adding files to vector stores are asynchronous and take time to complete. The SDK includes
106
-
helper functions which will poll the status until it reaches a terminal state and then return the resulting object.
107
-
If an API method results in an action which could benefit from polling there will be a corresponding version of the
108
-
method ending in 'AndPoll'.
109
-
110
-
For instance to create a Run and poll until it reaches a terminal state you can run:
111
-
112
-
```ts
113
-
const run =awaitopenai.beta.threads.runs.createAndPoll(thread.id, {
114
-
assistant_id: assistantId,
115
-
});
116
-
```
117
-
118
-
More information on the lifecycle of a Run can be found in the [Run Lifecycle Documentation](https://platform.openai.com/docs/assistants/how-it-works/run-lifecycle)
119
-
120
-
### Bulk Upload Helpers
121
-
122
-
When creating and interacting with vector stores, you can use the polling helpers to monitor the status of operations.
123
-
For convenience, we also provide a bulk upload helper to allow you to simultaneously upload several files at once.
0 commit comments