Skip to main content

Setup OpenAi API / GPT

Video Tutorial

Setup OpenAI Integration

Written Tutorial

To integrate the OpenAI API into your project, follow these steps:

1. Sign Up for OpenAI API

  • Visit OpenAI and navigate to the projects and OpenAI API login page.
  • Register for an account.

2. Create API Key

  • Once registered, log in to the API dashboard and create a new project.
  • After creating a new project, click the “API keys” button on the left side menu.
  • On the top right, click the “Create new secret key” button to generate a new key.
  • Copy the generated API key.

3. Update Environment Variables

  • Open the .env file in your app's source code.
  • Add the following line to the .env file, replacing [your-key] with the key you copied:
OPENAI_API_KEY=[your-key]

4. Test the Integration

  • You can now use the ChatGPT function inside the /lib/chatGPT folder in the app.
  • Test it out using a server component to ensure everything is set up correctly.