Skip to content

Commit 50dbc89

Browse files
committed
more readme work
1 parent 3f96a58 commit 50dbc89

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ await client.files.create({
126126

127127
## Streaming Helpers
128128

129+
The SDK makes it easy to stream responses, by providing an emitter helper via `.stream()`:
130+
129131
```ts
130132
import OpenAI from 'openai';
131133

@@ -154,6 +156,10 @@ async function main() {
154156
main();
155157
```
156158

159+
With `.stream()` you get event handlers, accumulation, and an async iterable.
160+
161+
Alternatively, you can use `client.chat.completions({ ..., stream: true })` which only returns an async iterable of the events in the stream and thus uses less memory (it does not build up a final message object for you).
162+
157163
## Tool Helpers
158164

159165
The SDK makes it easy to create and run [function tools with the chats API](https://platform.openai.com/docs/guides/function-calling). You can use Zod schemas or direct JSON schemas to describe the shape of tool input, and then you can run the tools using the `client.beta.messages.toolRunner` method. This method will automatically handle passing the inputs generated by the model into your tools and providing the results back to the model.

0 commit comments

Comments
 (0)