Skip to content

DefangSamples/sample-nodejs-openai-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node.js & OpenAI

1-click-deploy

A simple Node.js and OpenAI app deployed using Defang.

Prerequisites

  1. Download Defang CLI
  2. (Optional) If you are using Defang BYOC authenticate with your cloud provider account
  3. (Optional for local development) Docker CLI

Development

To run the application locally, you can use the following command:

docker compose up --build

Configuration

For this sample, you will need to provide the following configuration:

Note that if you are using the 1-click deploy option, you can set these values as secrets in your GitHub repository and the action will automatically deploy them for you.

OPENAI_KEY

An API key to access the OpenAI API.

defang config set OPENAI_KEY

Testing

Below are some useful commands for testing.

echo "Hello" | curl -H "Content-Type: text/plain" -d @- https://xxxxxxxx/prompt

or alternatively,

cat prompt.txt | curl -H "Content-Type: application/text" -d @- https://xxxxxxxx/prompt

Deployment

Note

Download Defang CLI

Defang Playground

Deploy your application to the Defang Playground by opening up your terminal and typing:

defang compose up

BYOC (AWS)

If you want to deploy to your own cloud account, you can use Defang BYOC:


Title: Node.js & OpenAI

Short Description: A simple Node.js application that interacts with the OpenAI API.

Tags: Node.js, OpenAI, API, JavaScript

Languages: nodejs

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 7