https://github.com/vinodnextcoder/openai-nodejs
openai nodejs example
https://github.com/vinodnextcoder/openai-nodejs
createchatcompletion createcompletion createembedding openai openai-chatgpt openai-javascript openai-node openai-nodejs
Last synced: 26 days ago
JSON representation
openai nodejs example
- Host: GitHub
- URL: https://github.com/vinodnextcoder/openai-nodejs
- Owner: vinodnextcoder
- License: gpl-3.0
- Created: 2023-06-08T06:23:43.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-08-02T06:45:59.000Z (over 2 years ago)
- Last Synced: 2024-12-29T05:12:10.703Z (about 1 year ago)
- Topics: createchatcompletion, createcompletion, createembedding, openai, openai-chatgpt, openai-javascript, openai-node, openai-nodejs
- Language: JavaScript
- Homepage:
- Size: 285 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# openai-nodejs
# OpenAI Node.js API Usage
This repository provides examples of using the OpenAI API with Node.js. It demonstrates how to use three different API endpoints: createEmbedding, createCompletion, and createChatCompletion. Each endpoint serves a specific purpose and has its own usage pattern.
# Prerequisites
Before running the examples, make sure you have the following:
Node.js installed on your machine.
OpenAI API key. You can obtain one from the OpenAI website.
Installation
Clone this repository: https://github.com/vinodnextcoder/openai-nodejs
# add api key
Open the config.js file.
Replace the YOUR_OPENAI_API_KEY sssdsdplaceholder with your actual OpenAI API key.
Usage
The repository includes examples for three different API endpoints: createEmbedding, createCompletion, and createChatCompletion. Here's how you can use each of them:
curl
curl --location 'http://localhost:3000/createEmbedding' \
--header 'Content-Type: application/json' \
--data '{
"text":"chat"
}'
curl --location 'http://localhost:3000/chatCompletion' \
--header 'Content-Type: application/json' \
--data '{
"text":"i am going to pune university"
}'
curl --location 'http://localhost:3000/createCompletion' \
--header 'Content-Type: application/json' \
--data '{
"text":"Write a tagline for an ice cream shop."
}'