A simple Node.js and OpenAI app deployed using Defang.
- Download Defang CLI
- (Optional) If you are using Defang BYOC authenticate with your cloud provider account
- (Optional for local development) Docker CLI
To run the application locally, you can use the following command:
docker compose up --buildFor 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.
An API key to access the OpenAI API.
defang config set OPENAI_KEYBelow are some useful commands for testing.
echo "Hello" | curl -H "Content-Type: text/plain" -d @- https://xxxxxxxx/promptor alternatively,
cat prompt.txt | curl -H "Content-Type: application/text" -d @- https://xxxxxxxx/promptNote
Download Defang CLI
Deploy your application to the Defang Playground by opening up your terminal and typing:
defang compose upIf 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