Goal
This tutorial will show you how to install, enable, and use the OpenAI Drupal module.
Prerequisites
- A Drupal 10 site
- Composer must be installed on your local machine.
- An OpenAI account
Overview
If you read Dries' blog post, Artificial Intelligence, the future of Content Management and the Web, you will know that he references Drupal integrations for ChatGPT created by Kevin Quillen. In this tutorial, we are going to deep dive on two of the modules from Drupal integrations for ChatGPT. Let's walk through installing and configuring the core OpenAI module and the OpenAI CKEditor integration, to start using OpenAI inside of a Drupal application.
-
Add OpenAI module
To add OpenAI to a Drupal 10 application, we need to add the OpenAI module.
Run the Composer command to add the OpenAI module to the codebase.
composer require 'drupal/openai:^1.0@alpha' -
Enable OpenAI and OpenAI CKEditor
To use the OpenAI module, we have to enable the core OpenAI module and one or more submodules.
For this tutorial we are going to use the OpenAI CKEditor integration module so we need enable OpenAI and OpenAI CKEditor integration.
Run the Drush command to enable OpenAI and OpenAI CKEditor integration modules.
drush en openai openai_ckeditor -y -
Create OpenAI API key
Before we can configure the OpenAI module, we need to create an OpenAI API key.
When logged into your OpenAI account, you can visit "View API Keys" to create a new API key.
To create an API Key, click on "+ Create new secret key."
Adding the OpenAI and the OpenAI CKEditor modules is only the beginning of using OpenAI within a Drupal application. Now that you have configured the core module, you can begin experimenting with the other features that come with the module.