Skip to content

Boburmirzo/apisix-api-gateway-chatgpt-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChatGPT Custom Plugin For API Gateway

This repo has source code for a custom ChatGPT Plugin for API Gateway. You can use it to add API Gateway features such as authentication, security, traffic management, observability, caching, and other functionalities for your backend APIs using ChatGPT UI and Apache APISIX.

See in action

ChatGPT Custom Plugin For API Gateway

If you want to use Apache APISIX API Gateway as a front door for communication between ChatGPT custom plugins and backend APIs, you can check this repo API Gateway between ChatGPT custom plugin and backend APIs

Read the full tutorial to understand the step-by-step and direct method of developing a ChatGPT Plugin for API Gateway.

How does it work?

As an example, in the ChatGPT user interface, if a user wants to introduce an API Gateway in front of an existing Conference API to obtain details about a speaker's sessions and topics, the plugin is capable of receiving commands in the chat and then forwards the user's request to the Apache APISIX Admin API, which create a Route with the user-specified input configuration. This can be another approach to using the Chatbot to configure the API Gateway features. See sample output to the prompt below:

Chatbot to configure the API Gateway features

After the command runs successfully, APISIX creates the route and registers an Upstream for our Conference backend API. So, you can access the API Gateway domain and URL path to get a response through the Gateway. For example, this GET request to http://localhost:9080/speaker/1/sessions endpoint returns all speaker’s sessions from Conference API. You can also do basic operations like get all routes and a route by Id directly by asking ChatGPT.

How to run it?

Prerequisites

To start the project run simply the following command from the project root directory:

docker compose up

When you start the project, Docker downloads any images it needs to run. You can see that APISIX, etcd and Python app (chatgpt-config) services are running.

ChatGPT Custom Plugin For API Gateway is running

Connect the custom plugin to the ChatGPT interface

If you have a Plus account, we must first enable the plugin in GPT-4 since it is disabled by default. We need to go to the settings and click the beta option and click “Enable plugins”. Then click the plugins pop bar on the top of ChatGPT, navigate to “Plugin Store” and select “Develop your own plugin”. Provide the local host URL for the plugin (localhost:5000).

Untitled

After you click on “Find a manifest file”, if everything is set it up correctly, you will see ChatGPT validates both manifest and OpenAPI spec files successfully.

Untitled

Step 3: Test the custom plugin

Now the plugin is connected to the ChatGPT interface, we can write a simple command:

Ask ChatGPT to create a Route

Other demo use cases:

  1. Create a Route with a plugin. image

  2. Show all existing routes. image

Next steps

Now you can take the sample project as a foundation and improve functionalities by adding more APISIX Admin API specifications to openapi.yaml file to use plugins and add API consumers and more. Feel free to contribute to the GitHub project by raising pull requests.

Community

🙋 Join the Apache APISIX Community

🐦 Follow us on Twitter

📝 Find us on Slack

💁 How to contribute page

About the author

Follow me on Twitter: @BoburUmurzokov

Visit my blog: www.iambobur.com