Everything you need to know to create a ChatGPT plugin

A deep dive into ChatGPT plugins development for beginners and curious explorers

Chandler K
10 min readJul 27, 2023
[Image by DALLE]
[Image by DALLE]

ChatGPT plugins provide a novel way to extend the core capabilities of ChatGPT. By default, ChatGPT is not currently connected to the internet so simple tasks like checking the weather in a location are not possible. But with plugins, developers can connect an API to ChatGPT and ChatGPT can send requests to get up to date information like the weather in San Francisco.

With a growing plugin store and over 700 plugins available to date, this new ecosystem has the potential to enable so many exciting use cases. While it is still too early to tell if this is true, many are calling the plugin store the new “App store” in reference to how large of an opportunity it is going to be. But what exactly is a plugin? How can developers get access to build them? What are some examples of simple starter plugins?

In this article, we will explain:

  • What a plugin is
  • How to become a plugin developer
  • The benefits of creating your own plugins
  • The process of creating a simple TODO list plugin

As a plugin developer myself, it has been awesome to see hundreds of people using my (very) simple plugins on a daily basis. The user community for plugins is extremely excited and trying to find tools that are worth using in their existing ChatGPT workflows. Let’s dive in!

What is a plugin?

Before we go further, it is worth being very clear about what a plugin actually is in the context of ChatGPT. According to the OpenAI documentation:

Plugins connect ChatGPT to third-party applications. These plugins enable ChatGPT to interact with APIs defined by developers, enhancing ChatGPT’s capabilities and allowing it to perform a wide range of actions.

The unique part about plugins is that, with one small exception, the plugin is really just a simple API. Developers have been building API’s for decades and it is great there is no new paradigm that needs to be adopted in order to enable the development of plugins.

There are three important parts of a plugin:

  • ai-plugin.json, the file which contains all the metadata about the plugin
  • openapi.yaml, the standard format to define the API
  • API, the actual API code that is running on a server and corresponding with the OpenAPI spec

As we explore the plugin landscape, these three pieces will be the recurring talking points as they make up much of the core components to consider when making a plugin.

If you are still at all confused about what a plugin is, consider going into ChatGPT and asking for the weather, then try the GPT-4 plugin model and use my WeatherWizard plugin to do the same. It is a simple but clear example of why plugins are so critical to many workflows in ChatGPT.

How to become a Plugin developer

Today, plugin developer access is not open to everyone. In order to develop ChatGPT Plugins, you have to be accepted into the developer program which requires ChatGPT plus. The waitlist can be joined from the above link by providing OpenAI with some basic information but the wait time could be a few weeks or more than a month.

Once accepted, you should see new items in the ChatGPT plugin store UI to “Develop your own plugin” or “Install a plugin”. These are the new features made available exclusively to plugin developers right now. The good news is that since the core technology powering plugins is a simple API, you can start building today without having access to plugins which will give you a head start.

Benefits of plugins

While GPT-3.5 and 4 are incredible tools, they can’t always be relied upon to produce accurate responses. Not only is the data it was trained on from 2021, but it can also simply return incorrect information (often referred to as hallucinations). This is where plugins come in. Want to be provided with numerous articles for varying perspectives, a plugin can be created that accesses an API with that data. Looking to find where to stream your favorite show? A plugin can be used to keep you up to date.

For developers, the core benefits to making a plugin are:

  • Awareness of your product
  • Acquiring new users
  • Enablement of new experiences

Most developers are building plugins as a means to acquire new users or to enable an experience that was not previously possible given the power of ChatGPT. There are also many hobbyist developers (like myself) who have been building plugins (Weather Wizard & Apex Map, with more coming soon) to get experience and better understand this technology. But the core value add for businesses is still user acquisition. ChatGPT has a massive user base of people who are deeply excited about AI, and willing to pay to access plugins (since it’s only for plus users). This means that if companies have a strong audience overlap they may be able to convert users at a much higher rate than in other cohorts of users.

Even after GPT-4’s message cap increase, developing and/or running plugins will still count towards your message limit. Luckily, there are multiple ways to get the most from this limit which you can read more about in my recent post.

Getting started building a plugin

Now that we have talked about the high level details of plugins, it is time to dive into building our own example plugin. The rest of this post is geared towards developers who want to build a plugin or those curious about how the process works. For this example, we will be building off the open source example created by OpenAI which is available on Github. The plugin will be a simple TODO list that allows the user to keep track of tasks. Once working, ChatGPT can add, remove, and edit items on the TODO list.

Side note, if you are like me and can use a little help coding new things, try to use ChatGPT’s new code interpreter mode while you make your plugin to accelerate the development. I covered the basics of it in a post I recently made:

The first step will be to download the Github repository locally. Included in the repo are several important files. Let’s look at each file and explore what they do step by step.

ai-plugin.json

The AI plugin file is a special custom made file just for plugins which defines all the key data about the plugin. If you are overwhelmed by what you see, we will take it line by line and go through what these items mean.

{
"schema_version": "v1",
"name_for_human": "TODO List (no auth)",
"name_for_model": "todo",
"description_for_human": "Manage your TODO list. You can add, remove and view your TODOs.",
"description_for_model": "Plugin for managing a TODO list, you can add, remove and view your TODOs.",
"auth": {
"type": "none"
},
"api": {
"type": "openapi",
"url": "http://localhost:5003/openapi.yaml"
},
"logo_url": "http://localhost:5003/logo.png",
"contact_email": "legal@example.com",
"legal_info_url": "http://example.com/legal"
}

Quickly going line by line, we see the following:

  • “schema_version”: This refers to the version number of the ai-plugin format and should be set to v1
  • “name_for_human”: This is simply the name of the plugin that the user will see in ChatGPT
  • “name_for_model”: The name of the plugin that is used INTERNALLY by the model
  • “description_for_human”: A brief description of the plugin that the user will see in the ChatGPT plugin store
  • “description_for_model”: This is a very important line of info. This gives a description of the plugin to the model so that it has the appropriate context regarding what the plugin is meant to do and can decide when to call the plugin based on a user query
  • “auth”: The authentication method. Here, “type” is “none”, which means the plugin doesn’t require authentication
  • “api”: The API type and its corresponding URL. “type” is “openapi” indicating OpenAPI specification is used. “url” is the link to the YAML file of the OpenAPI specification
  • “logo_url” : This is the URL where the plugin’s logo image can be found. It’s used for display in the ChatGPT UI
  • “contact_email”: The contact email address for any queries related to the plugin
  • “legal_info_url”: The URL where users can find the legal information related to the plugin

main.py

This Python file sets up a simple, asynchronous web server using the Quart framework to manage a TODO list on a per-user basis. The server provides endpoints for adding, retrieving, and deleting to-do items. It also hosts a logo and two configuration files: a JSON manifest for the plugin, and a YAML file describing the OpenAPI specification for the plugin. Note that main.py is the definition of the server. ChatGPT will never see this code and is not aware of it. Instead, the OpenAPI.yaml file which will be looked at later is the interface between ChatGPT and the server. This server code is where you as the developer have the most flexibility.

For this file, I will break the code into 3 sections. These include the imports and setups, routes and endpoints, and the main function.

Imports and setup

import json
import quart
import quart_cors
from quart import request
app = quart_cors.cors(quart.Quart(__name__), allow_origin="https://chat.openai.com")
# Keep track of todo's. Does not persist if the Python session is restarted.
_TODOS = {}

This section imports the packages needed to make the plugin run. It also initializes an instance of Quart and specifies that only cross origin requests from “https://chat.openai.com" are allowed to be made to the server (no need to worry about what this means to start). The global variable links users to their TODO list.

Routes and endpoints

If you looked at the following code and thought that it looked overwhelming, I’m right there with you. However, in reality these lines are simple. They are commands to the server to add and delete user strings while giving directions to the logo.png, json file, and essential elements.

  1. @app.post(“/todos/<string:username>”): The endpoint for adding a TODO item for a specific user. It takes a JSON object from the request body, which should contain a “todo” field representing the TODO item.
  2. @app.get(“/todos/<string:username>”): This endpoint retrieves the TODO list for a specific user. It responds with a JSON array of the user’s TODO list items.
  3. @app.delete(“/todos/<string:username>”): This endpoint deletes a TODO item for a specific user. It expects a JSON object from the request body containing a “todo_idx” field, which specifies the index of the TODO item to be deleted in the user’s TODO list.
  4. @app.get(“/logo.png”): This endpoint serves a static file named “logo.png”. It provides a logo for the plugin.
  5. @app.get(“/.well-known/ai-plugin.json”): This endpoint serves a JSON manifest file for the plugin which again has all the important metadata about the plugin.
  6. @app.get(“/openapi.yaml”): This endpoint serves a YAML file that contains the OpenAPI specification for the plugin.

Again, these are all use case specific functions, the required part is to make sure you are serving the YAML file, ai-plugin file, and logo file. It is also possible to have these items in a separate program not part of the core API logic itself.

openapi.yaml

This file is the easiest to work with when creating plugins. While you can develop the OpenAPI spec manually, I’ve found that ChatGPT is a great help to auto generate the majority of this file if given a main.py file. However, you may need to add/clarify several essential lines. These include the following:

  • Title: Name of your plugin
  • Version: The version number of the plugin.
  • Description: A description of the plugin and instruction about how the model should act(if necessary/desired)
  • Server: The url that directs to your server

How to run your plugin locally

Now that we have looked at what each part of the plugin does, it is time to run it and see a simple plugin in action. Once you have the repository downloaded locally, the next step is to install the required packages. The following command can be used to do so:

pip install -r requirements.txt

Once the packages are installed locally, run the following command to start the local server:

python main.py

Once the server is running, create a new ChatGPT conversation for plugins:

Use the drop down menu to select “Plugins” from the GPT-4 section.

Navigate to the “Plugin store” and then click “Develop your own plugin”. Going through the “Develop your own plugin” flow is required every time you make a change to your ai-plugin.json file since that file is cached (a copy is stored) on OpenAI’s servers.

Finally, enter in the Domain for the plugin. This was “localhost:5003” for the TODO list example.

If all went well, you should be able to send a message and ask something like “What is on my todo list” or “Add get groceries to my todo list” and ChatGPT will send a request to your local server (you should be able to see this happen in real time with the logs).

Hopefully this guide was a helpful step toward building your own ChatGPT plugins. If there are still any questions or if you’re just looking for another great source, check out OpenAI’s plugin introduction or drop a comment below and I will update the article to clarify any new questions. See you in the next article!

--

--

Chandler K

Harvard, UPenn, prev NASA , writing about AI, game development, and more..