Skip to content

This repository contains a boilerplate for creating a custom GPT actions API using FastAPI.

License

Notifications You must be signed in to change notification settings

JohnVersus/gpt-actions-python-vercel-boilerplate

Repository files navigation

ChatGPT Plugin - Python FastAPI, Vercel Boilerplate

This repository contains a boilerplate for creating a ChatGPT Plugin API using FastAPI.

If you find this repository useful, please consider giving it a star! 🌟

Prerequisites

Before you begin, ensure you know how to work with the following:

Developing Locally

  1. Clone this repository using the below git commands or you can clone the git template directly from github.
git clone https://github.com/JohnVersus/gpt-actions-python-vercel-boilerplate.git your_project_name

cd your_project_name
  1. Create a venv and install the required dependencies:
python3 -m venv venv

source venv/bin/activate

pip install -r requirements.txt
  1. Add the required env variables in .env file.

  2. Start the FastAPI server:

python3 main.py

You should now be able to visit http://localhost:8000 to see your API in action.

Files required to be updated to make your own plugin

  1. api/app.py holds the APP API routes. Modify them to build your own application.

  2. Once you have build the API of your plugin start the localhost server with python3 main.py command.

  3. Visit http://localhost:8000/openapi.json to view the openAPI json generated by FastAPI.

Testing the Plugin API Locally

  1. Navigate to http://localhost:8000/docs to access the interactive Swagger UI documentation. Here you can explore the available endpoints and test them out.

Deploying with Vercel

This boilerplate is designed to be deployed with Vercel. Please follow Vercel's deployment documentation for details.

Installing the Plugin on ChatGPT

  1. Deploy the API using Vercel or a platform of your choice.
  2. Make sure to fill the required env variables
  3. Go to ChatGPT > Create new GPT.
  4. Use the openAPI json url of your deployed server in the GPT action and import the API specs. For example: https://chatgpt-plugin-python-vercel-boilerplate.vercel.app/openapi.json is the url for the Bookstore template plugin.
  5. Fill the bearer API key field in actions if required and start testing.

Once the API is working as expected you can publish your GPT

Working Demo

Bookstore GPT URL: https://chat.openai.com/g/g-zDbUeWbMJ-bookstore

image

GPTs built using this repository

image

Releases

No releases published

Packages

No packages published