AI Tools

Gravity ships with support for generative AI images and text with ChatGPT and Dall-E.

1. Create an OpenAI API Key

You must register an account with OpenAI and create an API key. Then, add your API key to the .env file in Gravity:

2. Generating Text with ChatGPT

Import the OpenAI model and make a request using the following:

This function will return a text string from ChatGPT.

3. Generating Images with Dall-E

Import the OpenAI model and make a request using the following:

Size is optional - the default is 512x512 pixels. You can also specify the number of images to return; the default is 1.

This function will return an array of image objects with a url key containing your image.

Included Endpoints

There are pre-configured endpoints included for you to use from the client:

Last updated

Was this helpful?