Plugin Protocol

GPTBots Plugin is a plugin that can connect to third-party APIs and call third-party data and services through LLM.

The plugin protocol of GPTBots follows the OpenAPI Specification (OAS) format and defines a standard, language-independent HTTP API that allows humans and computers to understand the functions of the service.

Example

Plugin Protocol Fields
// Some code
{
  "openapi": "3.0.0",
  "servers": [
    {
      "url": "Requested domain name, must be in URL format. e.g. https://restapi.amap.com"
    }
  ],
  "paths": {
    "/api/custom/path": {
      "get": {
        "operationId": "Required. Name of API, can be composed of English and underscores, no spaces are allowed. e.g. getAdCode, get_Ad_Code"
        "description": "Required. Clear description of the API's function, the LLM will determine the timing of calling the API. 200 characters limited."
        "parameters": [
          {
            "name": "Required. Name of parameter field. e.g. key",
            "in": "Position of parameter. Supported: path/query (parameters appended after the url)/header (custom request headers used in the request)/cookie",
            "description":"Required. Clear description of parameters' meaning. 200 characters limited."
            "required": true,
            "schema": {
              "type": "Type of field. Supported: integer/number/string/boolean",
              "default": "Default value of parameter
              . e.g. e1a791daabb6b8d2bc8cb22633e37"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Description of responses",
            "content": {
              "*/*": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "Authentication failed"
          }
        }
      }
    },
    "post": {
        "operationId": "Required. Name of API, can be composed of English and underscores, no spaces are allowed. e.g. createUser",    
        "description":"Required. Clear description of the API's function, the LLM will determine the timing of calling the API. 200 characters limited."
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/User"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "User created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "Reference. e.g. #/components/schemas/User"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          }
        }
      }
    ,
  "components": {
    "schemas": {
      "User": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          }
        },
        "required": ["name", "email"]
      }
    }
  }
  }
}

Example: Weather Query Plugin
// Some code
{
  "openapi": "3.0.0",
  "servers": [
    {
      "url": "https://restapi.amap.com"
    }
  ],
  "paths": {
    "/v3/geocode/geo": {
      "get": {
        "description": "When weather or location information is available, call this API to obtain the adCode corresponding to the address.",
        "operationId": "getAdCode",
        "parameters": [
          {
            "name": "key",
            "in": "query",
            "description": "The key used for API authentication (default value: your_key)",
            "required": true,
            "schema": {
              "type": "string",
              "default": "your_key"
            }
          },
          {
            "name": "address",
            "in": "query",
            "description": "Address",
            "required": true,
            "schema": {
              "type": "string",
              "default": "Beijing"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "*/*": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "Authentication failed"
          }
        }
      }
    },
    "/v3/weather/weatherInfo": {
      "get": {
        "description": "When an adCode is obtained, use the adCode to query the weather.",
        "operationId": "queryWeather",
        "parameters": [
          {
            "name": "key",
            "in": "query",
            "description": "The key used for API authentication (default value: your_key)",
            "required": true,
            "schema": {
              "type": "string",
              "default": "your_key"
            }
          },
          {
            "name": "city",
            "in": "query",
            "description": "The adCode obtained from the previous request",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "extensions",
            "in": "query",
            "description": "Default value: all",
            "required": true,
            "schema": {
              "type": "string",
              "default": "all"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "*/*": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "Authentication failed"
          }
        }
      }
    }
  }
}

Fields Description

FieldRequiredDescription

operationId

Name of API, can be composed of English and underscores, no spaces are allowed. e.g. getAdCode, get_Ad_Code

description (API)

Clear description of the API's function, the LLM will determine the timing of calling the API. 200 characters limited.

parameters - name

Name of parameter field. e.g. key

parameters - in

Position of parameter. Supported: path/query (parameters appended after the url)/header (custom request headers used in the request)/cookie

parameters -description

Clear description of parameters' meaning. 200 characters limited.

parameters -type

Type of field. Supported: integer/number/string/boolean

Plugin Development Specification Guide

  • A plugin is allowed to contain up to 5 APIs, and GPTBots recommends that plugins should be configured with as few APIs as possible;

  • Developers should not try to control the mood, personality, or exact response of the LLM through the description;

  • The descriptions field should not encourage LLM to use the plugin when the user's question is not related to the specific service provided by the plugin;

  • Do not set specific trigger conditions for plugins;

  • Plugin API responses should return raw data, not natural language responses, unless necessary. LLM will use the returned data to provide its own natural language response.

Last updated