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! 🌟
Before you begin, ensure you know how to work with the following:
- 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
- Create a venv and install the required dependencies:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
-
Add the required env variables in .env file.
-
Start the FastAPI server:
python3 main.py
You should now be able to visit http://localhost:8000
to see your API in action.
-
api/app.py
holds the APP API routes. Modify them to build your own application. -
Once you have build the API of your plugin start the localhost server with
python3 main.py
command. -
Visit
http://localhost:8000/openapi.json
to view the openAPI json generated by FastAPI.
- Navigate to
http://localhost:8000/docs
to access the interactive Swagger UI documentation. Here you can explore the available endpoints and test them out.
This boilerplate is designed to be deployed with Vercel. Please follow Vercel's deployment documentation for details.
- Deploy the API using Vercel or a platform of your choice.
- Make sure to fill the required env variables
- Go to ChatGPT > Create new GPT.
- 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. - 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
Bookstore GPT URL: https://chat.openai.com/g/g-zDbUeWbMJ-bookstore