Published on

How to Connect OpenAI GPTs to APIs

Authors
  • Zdenek “Z” Nemec
    Name
    Zdenek “Z” Nemec
    Title
    Founder, CTO
    Social media profiles

Earlier this year, OpenAI announced GPTs: custom versions of their ChatGPT that can leverage your knowledge, instructions, and skills to build an agent suited for your tasks.

All but the most simple GPTs likely need to interact with some kind of external SaaS application (Salesforce, Xero, Twilio, Google, etc.) to retrieve information or to take action.

GPTs are not connected to anything out of the box, so their functionality is limited to what they already know.

To add that functionality to your OpenAI GPT, you need to connect to these external services through their APIs.

That’s where things start to get complicated.

Whilst you can create your custom GPTs without writing any code, to use an API, you’ll need to know the basics of APIs and also to be lucky enough to find an API has a usable specification (called an OpenAPI Specification, or OAS) that defines the functionality that the API offers.

Many SaaS applications don’t have an API specification. Even if they do, their specification is either very hard to find or is not usable by custom GPTs.

The fact is that real-world APIs are not designed to work with AI or they are simply too large and complex for AI to comprehend (for example, the Salesforce and GitHub APIs offer hundreds of operations).

A service that is designed with all this in mind is required. Enter, Superface.

Superface connects GPTs to APIs

Superface offers the best and fastest experience for authors of GPTs who want to connect SaaS services via (RESTful) APIs without any coding!

With Superface, you can configure the SaaS applications your GPT needs to use, authenticate and configure those applications, and then make all of them available to your GPT by adding a single Action to your configuration.

EOD prices retrieved via Superface connection to MarketStack

For example, we want our GPT to access stock market data using the MarketStack API (as shown above) that we then use to create and update a Google Sheet.

We would start by adding and authenticating both the MarketStack and Google Sheet toolkits in Superface:

Connecting toolkits inside Superface for use with OpenAI GPTs

Then, in our custom GPT configuration click “Create new action” in the “Actions” section at the bottom of the GPT configuration.

Configure your GPT to use an Action

Superface offers a single schema that defines all the tools added. Import the schema from the URL you obtain from the Superface settings.

Add the schema for your tools that Superface provides

Finally, set the Authentication Type to API Key and the Auth Type to Bearer, then fill in your Superface Authentication token from below the schema URL used in the last step.

Set the API key using the Bearer Authentication scheme

At this point, you can save your GPT and start using it. It now has access to all the tools you have added to Superface.

We strongly recommend not publishing your GPT, as it that would mean any user can access any tool you have configured in Superface. We recommend that you save the GPT as “Publish to Only Me.”

Set the publish setting for your GPT to Publish to Only Me

With your GPT saved, you can start with the query such as:

What were the Apple and Microsoft end-of-the-day prices last week?

Followed by:

Create a spreadsheet with these prices

The full example of the GPT connected to the APIs of MarketStack and Google Sheets

Your GPT now has unlimited connectivity possibilities to virtually any SaaS application or even your own internal APIs!

You can add more capabilities to your GPT at any point by adding more tools to Superface, configuring their credentials, and importing the Superface API specification again to update your GPT. You don’t need to configure the Superface authentication again when you update your GPT.

Get access to Superface for GPTs

Superface for GPTs launches in mid-January 2024, but if you are building GPTs and need to connect to SaaS applications today, let us know at hello@superface.ai and we'll secure your early access in return for your feedback.

References

OpenAI: Introducing GPTs

OpenAI: Create custom GPT

OpenAI: GPT actions

Connect your GPT to APIs for free.
Superface. The super interface for all your platforms.

Try it now