Skip to main content

Deploy an outline using AI

Defang supports generating new project outlines using integration with an AI model. Using this feature, you can describe what you would like the service to do and the CLI will then generate a project outline with all the files required to make it work.

In this tutorial we'll use the following prompt:

A basic service with 2 REST endpoints. The default endpoint will be for health check and should return a JSON object like this: { "status": "OK" }. The /echo endpoint will echo back all request parameters in the response.

Step 1 - Use the CLI generate command

defang generate

? Choose the language you'd like to use: [Use arrows to move, type to filter, ? for more help]
> Nodejs
Golang
Python

? Choose a sample service:
Generate with AI

? Please describe the service you'd like to build: [? for help]
A basic service with 2 REST endpoints. The default endpoint will be for health check and should return a JSON object like this: { "status": "OK" }. The /echo endpoint will echo back all request parameters in the response.

? What folder would you like to create the service in? [? for help] (service1)
project1

This will generate the different files required to start your project based on your prompt and the language selected.

Step 2 - Review the Code

Change into the new project folder:

cd project1

You can open the files in a code editor to review or make changes as needed before deploying the service.

Step 3 - Build and Deploy

defang compose up