Skip to content

Commit 514a02a

Browse files
Update README.md
1 parent 768211a commit 514a02a

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

README.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,33 @@
11
# OpenAI API Quickstart - Node.js example app
22

3-
This is an example pet name generator app used in the OpenAI API [quickstart tutorial](https://platform.openai.com/docs/quickstart). It uses the [Next.js](https://nextjs.org/) framework with [React](https://reactjs.org/). Check out the tutorial or follow the instructions below to get set up.
3+
This is an example chat app intended to get you started with your first OpenAI API project. It uses the [Chat Completions API](https://platform.openai.com/docs/api-reference/chat) to create a simple general purpose chat app with streaming.
44

5-
![Text box that says name my pet with an icon of a dog](https://user-images.githubusercontent.com/10623307/213887080-b2bc4645-7fdb-4dbd-ae42-efce00d0dc29.png)
5+
## Basic request
66

7+
To send your first API request with the [OpenAI Node SDK](https://github.com/openai/openai-node), make sure you have the right [dependencies installed](https://platform.openai.com/docs/quickstart?context=node) and then run the following code:
8+
9+
```python
10+
import OpenAI from "openai";
11+
12+
const openai = new OpenAI();
13+
14+
async function main() {
15+
const completion = await openai.chat.completions.create({
16+
messages: [{ role: "system", content: "You are a helpful assistant." }],
17+
model: "gpt-3.5-turbo",
18+
});
19+
20+
console.log(completion.choices[0]);
21+
}
22+
23+
main();
24+
```
25+
26+
This quickstart app builds on top of the example code above, with streaming and a UI to visualize messages.
727

828
## Setup
929

10-
1. If you don’t have Node.js installed, [install it from here](https://nodejs.org/en/) (Node.js version >= 14.6.0 required)
30+
1. If you don’t have Node.js installed, install it from [nodejs.org](https://nodejs.org/en/) (Node.js version >= 16.0.0 required)
1131

1232
2. Clone this repository
1333

0 commit comments

Comments
 (0)