cURL commands to test TODO plugin server independent of ChatGPT

Was not having success getting first plugin to work as expected with Develop your own plugin, so installed the TODO plugin based on Python and then looked at the console messages. Using the console messages recreated cURL commands so that the TODO plugin could be tested independent of ChatGPT and give some idea of what was expected. Learned a few things so sharing this in the hopes it may help you also.


Note this was done on Windows so the cURL command delimiter syntax may need to be modified , e.g.

curl -X POST -H "Content-Type: application/json" -d "{\"todo\":\"Send flowers\"}" http://localhost:5003/todos/user?username=john

might work better as

curl -X POST -H 'Content-Type: application/json' -d '{"todo":"Send flowers"}' http://localhost:5003/todos/user?username=john

Console messages when using TODO demo based on Python.

Click triangle to expand
C:\Users\Groot\plugins-quickstart-main>python main.py
 * Serving Quart app 'main'
 * Environment: production
 * Please use an ASGI server (e.g. Hypercorn) directly in production
 * Debug mode: True
 * Running on http://0.0.0.0:5003 (CTRL + C to quit)
[2023-05-18 07:01:32 -0400] [15008] [INFO] Running on http://0.0.0.0:5003 (CTRL + C to quit)
[2023-05-18 07:03:06 -0400] [15008] [INFO] 127.0.0.1:63017 OPTIONS /.well-known/ai-plugin.json 1.1 200 0 19001
[2023-05-18 07:03:06 -0400] [15008] [INFO] 127.0.0.1:63017 GET /.well-known/ai-plugin.json 1.1 200 641 18982
[2023-05-18 07:03:06 -0400] [15008] [INFO] 127.0.0.1:63017 OPTIONS /openapi.yaml 1.1 200 0 10976
[2023-05-18 07:03:06 -0400] [15008] [INFO] 127.0.0.1:63017 GET /openapi.yaml 1.1 200 2337 17019
[2023-05-18 07:03:07 -0400] [15008] [INFO] 127.0.0.1:63017 OPTIONS /logo.png 1.1 200 0 15002
[2023-05-18 07:03:07 -0400] [15008] [INFO] 127.0.0.1:63025 GET /logo.png 1.1 200 1268 139032
[2023-05-18 07:03:15 -0400] [15008] [INFO] 127.0.0.1:63029 OPTIONS /.well-known/ai-plugin.json 1.1 200 0 10003
[2023-05-18 07:03:15 -0400] [15008] [INFO] 127.0.0.1:63029 GET /.well-known/ai-plugin.json 1.1 200 641 12006
[2023-05-18 07:03:15 -0400] [15008] [INFO] 127.0.0.1:63029 OPTIONS /openapi.yaml 1.1 200 0 11006
[2023-05-18 07:03:15 -0400] [15008] [INFO] 127.0.0.1:63029 GET /openapi.yaml 1.1 200 2337 9989
[2023-05-18 07:03:37 -0400] [15008] [INFO] 127.0.0.1:63038 OPTIONS /.well-known/ai-plugin.json 1.1 200 0 9002
[2023-05-18 07:03:37 -0400] [15008] [INFO] 127.0.0.1:63038 GET /.well-known/ai-plugin.json 1.1 200 641 12001
[2023-05-18 07:03:37 -0400] [15008] [INFO] 127.0.0.1:63038 OPTIONS /openapi.yaml 1.1 200 0 10998
[2023-05-18 07:03:37 -0400] [15008] [INFO] 127.0.0.1:63038 GET /openapi.yaml 1.1 200 2337 11988
[2023-05-18 07:04:06 -0400] [15008] [INFO] 127.0.0.1:63046 OPTIONS /todos/user 1.1 200 0 9979
[2023-05-18 07:04:06 -0400] [15008] [INFO] 127.0.0.1:63046 POST /todos/user 1.1 200 2 19988
[2023-05-18 07:04:24 -0400] [15008] [INFO] 127.0.0.1:63052 OPTIONS /todos/user 1.1 200 0 10002
[2023-05-18 07:04:24 -0400] [15008] [INFO] 127.0.0.1:63052 POST /todos/user 1.1 200 2 19999
[2023-05-18 07:04:37 -0400] [15008] [INFO] 127.0.0.1:63056 OPTIONS /todos/user 1.1 200 0 11027
[2023-05-18 07:04:37 -0400] [15008] [INFO] 127.0.0.1:63056 GET /todos/user 1.1 200 27 13002
[2023-05-18 07:05:04 -0400] [15008] [INFO] 127.0.0.1:63060 OPTIONS /todos/user 1.1 200 0 11005
[2023-05-18 07:05:04 -0400] [15008] [INFO] 127.0.0.1:63060 DELETE /todos/user 1.1 200 2 16987
[2023-05-18 07:05:20 -0400] [15008] [INFO] 127.0.0.1:63066 OPTIONS /todos/user 1.1 200 0 10980
[2023-05-18 07:05:20 -0400] [15008] [INFO] 127.0.0.1:63066 GET /todos/user 1.1 200 15 13015

Recreation of ChatGPT HTTP request to TODO server. Created these to test the TODO server independent of ChatGPT.

Click triangle to expand
C:\Users\Groot>curl -X OPTIONS "http://localhost:5003/.well-known/ai-plugin.json" -i
HTTP/1.1 200
allow: OPTIONS, HEAD, GET
content-type: text/html; charset=utf-8
content-length: 0
date: Thu, 18 May 2023 11:45:09 GMT
server: hypercorn-h11

Server log

[2023-05-18 07:45:09 -0400] [15008] [INFO] 127.0.0.1:63214 OPTIONS /.well-known/ai-plugin.json 1.1 200 0 11011

C:\Users\Groot>curl -X GET "http://localhost:5003/.well-known/ai-plugin.json"
{
    "schema_version": "v1",
    "name_for_human": "TODO Plugin (no auth)",
    "name_for_model": "todo",
    "description_for_human": "Plugin for managing a 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",
      "is_user_authenticated": false
    },
    "logo_url": "http://localhost:5003/logo.png",
    "contact_email": "legal@example.com",
    "legal_info_url": "http://example.com/legal"
  }

Server log

[2023-05-18 07:48:03 -0400] [15008] [INFO] 127.0.0.1:63218 GET /.well-known/ai-plugin.json 1.1 200 641 24988

C:\Users\Groot>curl -X OPTIONS "http://localhost:5003/openapi.yaml" -i
HTTP/1.1 200
allow: OPTIONS, HEAD, GET
content-type: text/html; charset=utf-8
content-length: 0
date: Thu, 18 May 2023 11:57:13 GMT
server: hypercorn-h11

Server log

[2023-05-18 07:57:13 -0400] [15008] [INFO] 127.0.0.1:63246 OPTIONS /openapi.yaml 1.1 200 0 9999

C:\Users\Groot>curl -X GET "http://localhost:5003/openapi.yaml"
openapi: 3.0.1
info:
  title: TODO Plugin
  description: A plugin that allows the user to create and manage a TODO list using ChatGPT. If you do not know the user's username, ask them first before making queries to the plugin. Otherwise, use the username "global".
  version: 'v1'
servers:
  - url: http://localhost:5003
paths:
  /todos/{username}:
    get:
      operationId: getTodos
      summary: Get the list of todos
      parameters:
      - in: path
        name: username
        schema:
            type: string
        required: true
        description: The name of the user.
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/getTodosResponse'
    post:
      operationId: addTodo
      summary: Add a todo to the list
      parameters:
      - in: path
        name: username
        schema:
            type: string
        required: true
        description: The name of the user.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/addTodoRequest'
      responses:
        "200":
          description: OK
    delete:
      operationId: deleteTodo
      summary: Delete a todo from the list
      parameters:
      - in: path
        name: username
        schema:
            type: string
        required: true
        description: The name of the user.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/deleteTodoRequest'
      responses:
        "200":
          description: OK

components:
  schemas:
    getTodosResponse:
      type: object
      properties:
        todos:
          type: array
          items:
            type: string
          description: The list of todos.
    addTodoRequest:
      type: object
      required:
      - todo
      properties:
        todo:
          type: string
          description: The todo to add to the list.
          required: true
    deleteTodoRequest:
      type: object
      required:
      - todo_idx
      properties:
        todo_idx:
          type: integer
          description: The index of the todo to delete.
          required: true

Server log

[2023-05-18 07:59:22 -0400] [15008] [INFO] 127.0.0.1:63250 GET /openapi.yaml 1.1 200 2337 19989

C:\Users\Groot>curl -X OPTIONS "http://localhost:5003/logo.png" -i
HTTP/1.1 200
allow: OPTIONS, HEAD, GET
content-type: text/html; charset=utf-8
content-length: 0
date: Thu, 18 May 2023 12:07:48 GMT
server: hypercorn-h11

Server log

[2023-05-18 08:07:48 -0400] [15008] [INFO] 127.0.0.1:63273 OPTIONS /logo.png 1.1 200 0 11997

C:\Users\Groot>curl -X GET "http://localhost:5003/logo.png"
Warning: Binary output can mess up your terminal. Use "--output -" to tell
Warning: curl to output it to your terminal anyway, or consider "--output
Warning: <FILE>" to save to a file.

Server log

[2023-05-18 08:10:47 -0400] [15008] [INFO] 127.0.0.1:63281 GET /logo.png 1.1 200 1268 35994

C:\Users\Groot>curl -X OPTIONS "http://localhost:5003/todos/user" -i
HTTP/1.1 200
allow: DELETE, OPTIONS, HEAD, POST, GET
content-type: text/html; charset=utf-8
content-length: 0
date: Thu, 18 May 2023 12:12:24 GMT
server: hypercorn-h11

Server log

[2023-05-18 08:12:24 -0400] [15008] [INFO] 127.0.0.1:63287 OPTIONS /todos/user 1.1 200 0 9999

C:\Users\Groot>curl -X POST -H "Content-Type: application/json" -d "{\"todo\":\"Send flowers\"}" http://localhost:5003/todos/user?username=john
OK

Server log

[2023-05-18 08:30:42 -0400] [15008] [INFO] 127.0.0.1:63351 POST /todos/user 1.1 200 2 13999

C:\Users\Groot>curl -X GET http://localhost:5003/todos/user?username=john
["Buy flowers", "Send flowers"]

Server log

[2023-05-18 08:32:28 -0400] [15008] [INFO] 127.0.0.1:63356 GET /todos/user 1.1 200 31 11022

C:\Users\Groot>curl -X DELETE -H "Content-Type: application/json" -d "{\"todo_idx\":1}" http://localhost:5003/todos/user?username=johnn
OK

Server log

[2023-05-18 08:35:30 -0400] [15008] [INFO] 127.0.0.1:63361 DELETE /todos/user 1.1 200 2 14014

CORS version of cURL commands

Summary
C:\Users\Groot>curl -X OPTIONS "http://localhost:5003/.well-known/ai-plugin.json" -H "Origin: https://chat.openai.com" -i
HTTP/1.1 200
allow: HEAD, GET, OPTIONS
content-type: text/html; charset=utf-8
content-length: 0
access-control-allow-origin: https://chat.openai.com
access-control-expose-headers: ""
vary: Origin
date: Thu, 18 May 2023 14:13:52 GMT
server: hypercorn-h11

Server log

[2023-05-18 10:13:52 -0400] [11668] [INFO] 127.0.0.1:63716 OPTIONS /.well-known/ai-plugin.json 1.1 200 0 41977

C:\Users\Groot>curl -H "Origin: https://chat.openai.com" -X GET "http://localhost:5003/.well-known/ai-plugin.json"
{
    "schema_version": "v1",
    "name_for_human": "TODO Plugin (no auth)",
    "name_for_model": "todo",
    "description_for_human": "Plugin for managing a 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",
      "is_user_authenticated": false
    },
    "logo_url": "http://localhost:5003/logo.png",
    "contact_email": "legal@example.com",
    "legal_info_url": "http://example.com/legal"
  }

Server log

[2023-05-18 10:24:09 -0400] [11668] [INFO] 127.0.0.1:63752 GET /.well-known/ai-plugin.json 1.1 200 641 19003

C:\Users\Groot>curl -H "Origin: https://chat.openai.com" -X OPTIONS "http://localhost:5003/openapi.yaml" -i
HTTP/1.1 200
allow: HEAD, GET, OPTIONS
content-type: text/html; charset=utf-8
content-length: 0
access-control-allow-origin: https://chat.openai.com
access-control-expose-headers: ""
vary: Origin
date: Thu, 18 May 2023 14:25:34 GMT
server: hypercorn-h11

Server log

[2023-05-18 10:25:34 -0400] [11668] [INFO] 127.0.0.1:63756 OPTIONS /openapi.yaml 1.1 200 0 12002

C:\Users\Groot>curl -H "Origin: https://chat.openai.com" -X GET "http://localhost:5003/openapi.yaml"
openapi: 3.0.1
info:
  title: TODO Plugin
  description: A plugin that allows the user to create and manage a TODO list using ChatGPT. If you do not know the user's username, ask them first before making queries to the plugin. Otherwise, use the username "global".
  version: 'v1'
servers:
  - url: http://localhost:5003
paths:
  /todos/{username}:
    get:
      operationId: getTodos
      summary: Get the list of todos
      parameters:
      - in: path
        name: username
        schema:
            type: string
        required: true
        description: The name of the user.
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/getTodosResponse'
    post:
      operationId: addTodo
      summary: Add a todo to the list
      parameters:
      - in: path
        name: username
        schema:
            type: string
        required: true
        description: The name of the user.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/addTodoRequest'
      responses:
        "200":
          description: OK
    delete:
      operationId: deleteTodo
      summary: Delete a todo from the list
      parameters:
      - in: path
        name: username
        schema:
            type: string
        required: true
        description: The name of the user.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/deleteTodoRequest'
      responses:
        "200":
          description: OK

components:
  schemas:
    getTodosResponse:
      type: object
      properties:
        todos:
          type: array
          items:
            type: string
          description: The list of todos.
    addTodoRequest:
      type: object
      required:
      - todo
      properties:
        todo:
          type: string
          description: The todo to add to the list.
          required: true
    deleteTodoRequest:
      type: object
      required:
      - todo_idx
      properties:
        todo_idx:
          type: integer
          description: The index of the todo to delete.
          required: true

Server log

[2023-05-18 10:27:21 -0400] [11668] [INFO] 127.0.0.1:63759 GET /openapi.yaml 1.1 200 2337 74023

C:\Users\Groot>curl -H "Origin: https://chat.openai.com" -X OPTIONS "http://localhost:5003/logo.png" -i
HTTP/1.1 200
allow: HEAD, GET, OPTIONS
content-type: text/html; charset=utf-8
content-length: 0
access-control-allow-origin: https://chat.openai.com
access-control-expose-headers: ""
vary: Origin
date: Thu, 18 May 2023 14:28:53 GMT
server: hypercorn-h11

Server log

[2023-05-18 10:28:53 -0400] [11668] [INFO] 127.0.0.1:63762 OPTIONS /logo.png 1.1 200 0 13971

C:\Users\Groot>curl -H "Origin: https://chat.openai.com" -X GET "http://localhost:5003/logo.png"
Warning: Binary output can mess up your terminal. Use "--output -" to tell
Warning: curl to output it to your terminal anyway, or consider "--output
Warning: <FILE>" to save to a file.

Server log

[2023-05-18 10:29:41 -0400] [11668] [INFO] 127.0.0.1:63765 GET /logo.png 1.1 200 1268 163999

C:\Users\Groot>curl -H "Origin: https://chat.openai.com" -X OPTIONS "http://localhost:5003/todos/user" -i
HTTP/1.1 200
allow: DELETE, HEAD, GET, POST, OPTIONS
content-type: text/html; charset=utf-8
content-length: 0
access-control-allow-origin: https://chat.openai.com
access-control-expose-headers: ""
vary: Origin
date: Thu, 18 May 2023 14:30:38 GMT
server: hypercorn-h11

Server log

[2023-05-18 10:30:38 -0400] [11668] [INFO] 127.0.0.1:63767 OPTIONS /todos/user 1.1 200 0 11001

C:\Users\Groot>curl -H "Origin: https://chat.openai.com" -X POST -H "Content-Type: application/json" -d "{\"todo\":\"Send flowers\"}" http://localhost:5003/todos/user?username=john
OK

Server log

[2023-05-18 10:31:57 -0400] [11668] [INFO] 127.0.0.1:63769 POST /todos/user 1.1 200 2 40017

C:\Users\Groot>curl -H "Origin: https://chat.openai.com" -X GET http://localhost:5003/todos/user?username=john
["Send flowers"]

Server log

[2023-05-18 10:32:47 -0400] [11668] [INFO] 127.0.0.1:63772 GET /todos/user 1.1 200 16 10999

C:\Users\Groot>curl -H "Origin: https://chat.openai.com" -X DELETE -H "Content-Type: application/json" -d "{\"todo_idx\":1}" http://localhost:5003/todos/user?username=johnn
OK

Server log

[2023-05-18 10:33:47 -0400] [11668] [INFO] 127.0.0.1:63775 DELETE /todos/user 1.1 200 2 12999

Original info from here.

Since the plugins require OpenAPI specs, you can also import that file into various HTTP/API testing tools if you’d prefer a GUI

2 Likes