Connect to the OpenAI API from Supabase

Harness the power of AI in your apps from within your Supabase project, by creating a connection to the OpenAI API.

With another look at the Supabase http extension, we connect to the OpenAI API to use the Dall-e-3 image generation model. We will be making the API request via http, sending a prompt to the API and returning the url of our generated image that we can then use in our applications.

Here is the video and all of the code used is available below.

https://youtu.be/MX8qfc67zD0

Custom code for connecting to the OpenAI API

This is the function that connects to the API and returns an image based on your propmpt.

This is the code we use to call the create_image function from within the SQL editor. Remember to change the prompt to the image you want to create.

This is the function to create your private schema and the table to store your API keys.