Skip to main content

Developing ChatGPT Plugins with SQL

· 3 min read

ChatGPT plugins let you plug in your custom APIs to enable OpenAI to talk to your company data and take actions via triggering API calls. The integration is pretty seamless; you write a manifest file and explain when ChatGPT should call your plugin. The manifest file has a reference to your OpenAPI spec which includes your API endpoints and ChatGPT automagically generates an API call and calls your API when you ask questions.

The generative AI models usually don't have access to real-time data, they need to be trained in advance. As of today, ChatGPT's cutoff date is 2021 which means that it doesn't know what happened after 2021. The only way for it to access the real-time and private data is through the ChatGPT Plugins. Jinjat helps you connect your data in your data warehouse to ChatGPT. Here are the steps:

You can find the source code here of our sample ChatGPT plugin here:

Setup manifest file

Create the following file and edit the description about of data source. You can see the documentation about the properties here. Jinjat will serve the files under /static directory by default so OpenAPI will hit our API running locally.

"schema_version": "v1",
"name_for_human": "ACME Company Data",
"name_for_model": "acme_company_data",
"description_for_human": "Plugin for fetching the company data including business metrics including website, marketing, finance data",
"description_for_model": "Plugin for fetching the company data including business metrics including website, marketing, finance data",
"auth": {
"type": "none"
"api": {
"type": "openapi",
"url": "http://localhost:8581/current/openapi.json",
"is_user_authenticated": false
"logo_url": "",
"contact_email": "[email protected]",
"legal_info_url": ""

Next, we will enable CORS for OpenAI so that it can access Jinjat which is running locally.

- ""
- ""

That's all! Let's register our app in the plugin store.

1. Plugin Store

Plugin Store

2. Enter Domain

Enter Domain

Install Plugin

Install Plugin

It's enabled

Looking good, now we see our plugin in ChatGPT UI. 🚀 We're ready to ask our first question.


Looks like magic, right? ChatGPT was smart enough to find the relevant analyses, generate the API query, fetch it from Jinjat and nicely format it for us. The data is from 2018 because our source data doesn't actually include anything useful for this year so it's expected. ChatGPT also added a note about the expenses as we have the relevant description for expenses below:

version: 2
- name: expenses
description: Get product expenses for all the company

You can see all the API endpoints / dbt analyses on Github, create new SQL files which will generate an endpoint automatically. Developing a plugin for OpenAI usually requires some prompt engineering to tune for the queries that you expect because OpenAI can get confused if your API contract is complex, it's usually recommended to add notes to your yml files. You can find relevant docs below:

ChatGPT handles the cases where our API returns too much data as well. Jinjat returns 413 Status code which makes OpenGPT breakdown the queries into two chunks and merge them.