Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
O

openai-quickstart-node

> AI 编程
Open source

Node.js example app from the OpenAI API quickstart tutorial

2.6K stars0 likes2 views
WebsiteGitHub

About

Node.js example app from the OpenAI API quickstart tutorial

# OpenAI API Quickstart - Node.js This repository provides a collection of examples demonstrating how to use the OpenAI APIs with the Node.js SDK. The examples are organized by API, with each folder dedicated to a specific API: - Chat Completions - Assistants - Fine-tuning - Embeddings - Moderation - Batch Processing - Images Within each folder, you'll find a basic example to get started. For some APIs, additional examples are also included to explore more advanced use cases. ## Prerequisites To run the examples with the Node.js SDK, you will need: - A recent version of [Node.js](https://nodejs.org/) (>= 16.0.0) - A recent version of [npm](https://www.npmjs.com/) or another node package manager - An OpenAI API key (you can get one from your [OpenAI dashboard](https://platform.openai.com/settings/organization/api-keys)) ## How to use 1. Clone this repository ```bash $ git clone https://github.com/openai/openai-quickstart-node.git ``` 2. Navigate into the project directory ```bash $ cd openai-quickstart-node ``` 3. Install the OpenAI Node.js SDK ```bash $ npm install openai ``` 4. Set your OpenAI API key in environment variables **In the terminal session:** Bash (Mac/Linux): ```bash $ export OPENAI_API_KEY= ``` PowerShell (Windows): ```bash $ setx OPENAI_API_KEY "" ``` **Set it globally:** Add this line to your `.bashrc` or `.zshrc` file on Mac/Linux: ```bash $ export OPENAI_API_KEY= ``` Or update your system environment variables on Windows. 5. Run each script individually ```bash $ node path/to/script.js ``` For example, to run the basic chat completions example: ```bash $ node chat_completions/index.js ``` ## Examples Explore the examples below to learn how to use the Node.js SDK for your specific use case.
API Example Path
Chat Completions Basic example chat_completions/index.js
Multi-turn conversation chat_completions/multi_turn.js
Function Calling chat_completions/function_calling.js
Vision (image input) chat_completions/vision.js
Assistants Create an assistant assistants/index.js
Example thread assistants/thread.js {assistant-id}
Fine-tuning Create a fine-tuned model fine_tuning/index.js
Use a fine-tuned model fine_tuning/use_model.js {job-id}
Embeddings Generate embeddings embeddings/index.js
Moderation Moderate text moderation/index.js
Moderate images & text moderation/images.js
Batch Create a batch job batch/index.js
Get batch job results batch/retrieve_results.js {job-id}
Images Generate an image images/index.js
## Additional Resources For more in-depth examples within front-end applications, including with streaming responses, check out these additional resources: - [Assistants API Quickstart](https://github.com/openai/openai-assistants-quickstart) - [Sample apps with Structured Outputs](https://github.com/openai/openai-structured-outputs-samples)

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScriptopenaiopenai-api

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
CategoryAI 编程
PricingOpen source

> Related tools

G
GitHub Copilot
GitHub 官方 AI 编程助手,覆盖补全、Chat 与 Agent 模式。
C
Cursor
AI 原生代码编辑器,对话改代码、多文件 Agent 与规则体系是其核心。
S
skills
Skills for Real Engineers. Straight from my .agents directory.