DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • AI-Powered Flashcard Application With Next.js, Clerk, Firebase, Material UI, and LLaMA 3.1
  • Build an AI Chatroom With ChatGPT and ZK by Asking It How!
  • GenAI: From Prompt to Production
  • Grounding Gemini With Google Search and Other Data Sources

Trending

  • How Large Tech Companies Architect Resilient Systems for Millions of Users
  • AI’s Role in Everyday Development
  • Performing and Managing Incremental Backups Using pg_basebackup in PostgreSQL 17
  • Unmasking Entity-Based Data Masking: Best Practices 2025
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. How to Build an OpenAI Custom GPT With a Third-Party API

How to Build an OpenAI Custom GPT With a Third-Party API

This tutorial demonstrates how to build a conversational user interface with OpenAI's Custom GPT using any third-party API.

By 
Akhilesh Joshi user avatar
Akhilesh Joshi
·
Sep. 12, 24 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
5.0K Views

Join the DZone community and get the full member experience.

Join For Free

With the advent of Large Language Models (LLM), the conversational user interface has become very popular. You simply ask what you're seeking, and ChatGPT produces an output. In addition, the model can perform actions in response to your command or question and present you with the result. This opened up a huge opportunity to build a new kind of interface where the only input is the user's words — written or spoken.

This is fantastic, as you can imagine the limitless possibilities. What we need is for LLMs to have access to as many complex, real-world actions as possible, which they can then invoke appropriately. This is where third-party APIs come into the picture.

Platform APIs

Pick any popular internet service and imagine an API for it that can be invoked to perform the tasks usually performed by that service. Each service usually provides a nice graphical user interface (GUI) — either as a web app or mobile app — and users login to use it. But instead, what if the user only has to ask one single entity — the LLM's command interface — through text or audio commands? You wouldn't need any other interface.

It's interesting because now you can build a custom version of GPT that knows how to perform certain actions extremely well, becoming a specialist by being aware of the existence of such actions. It connects the user's intent with the desired action and shares the results (output) of the performed action.

OpenAPI YAML Specification

In the case of Custom GPT, this is achieved by registering any third-party API using their OpenAPI specification. For example, here is an OpenAPI specification of a platform for AI interior design. The API lets you create a new interior design using just a photo of the room. While the platform offers its own web app where users can upload the room photo and select interior design styles to generate a new interior design, you can bring this functionality to your platform by deploying it as a custom GPT.

Let's build a custom GPT with this API as an example. You can onboard any third-party API with its OpenAPI Spec. There are also tools available that will help you build an OpenAPI Spec for your own platform APIs. I believe it's a great way to distribute your own API to wider platforms.

Get the Platform API 

Most SaaS platforms offer their API so that developers can build their apps. They also publish an OpenAPI spec. Download the spec. It's a YAML file that looks like:

YAML
 
openapi: 3.1.0
info:
  title: Decor8AI Virtual Staging & Interior Design API
  version: "1.0"
  description: >
    Decor8 AI is a state-of-the-art virtual staging solution designed for realtors and real estate app developers. It provides a suite of customization options to create and visualize appealing interiors from empty spaces. With its focus on enhancing marketability, it's an essential tool for showcasing property potential in a compelling way.
    Please reach out to [Decor8 AI Team](mailto:decor8@immex.tech) with questions or suggestions.

    Additional license information can be found [here](https://github.com/immex-tech/decor8ai-sdk/blob/main/API_LICENSE_NOTICE).

    ### Getting Started

    - **Authentication**: Each API request requires two headers:
      - `Content-Type: application/json`
      - `Authorization: Bearer <API_KEY>`

    - **API Key**: Get your `<API_KEY>` from your account at [prod-app.decor8.ai](https://prod-app.decor8.ai).
  
    ### Sign in to [Decor8 AI](https://prod-app.decor8.ai) and Click on APIs from the Left Side-menu

    ![](https://github.com/immex-tech/decor8ai-sdk/blob/main/media/step_1.jpg?raw=true)

    ### Click Generate API Key
    ![](https://github.com/immex-tech/decor8ai-sdk/blob/main/media/step_2.jpg?raw=true)

    ### Test the AI Key 
    Once you have the key, run simple curl command to test the key.

    ```
    curl -X GET "https://api.decor8.ai/speak_friend_and_enter" -H "Authorization: Bearer <API_KEY>"
    ``` 

  license:
    name: Decor8AI SDK License
    url: https://github.com/immex-tech/decor8ai-sdk/blob/main/LICENSE
servers:
  - url: https://api.decor8.ai
    description: Base API URL for all endpoints.


Note: this is not a complete OpenAPI Spec but just a few lines of the file to give you an idea.

Open AI Custom GPT

You need an Open AI subscription to create a Custom GPT. Head to https://chat.openai.com/ and click on your profile picture in the top right corner of the page. 

OpenAI profile dropdown menu

Click on the "My GPTs" menu. Here, we will create a new Custom GPT (I already had created one Custom GPT and hence you see it already on this page.)

"My GPTs" menu

Click on "Create a GPT". You're presented with a form to define the properties of this custom GPT.

Form to define properties of the custom GPT

Click on the "Configure" tab.

Configure tab

Provide the Logo, Name, Description, and initial instructions.

In the instructions, it's important to define ground rules. For instance, you would want to define what should GPT do when users ask questions outside of GPT's expertise. GPT could say, "I don't know," or let the user know what it can do for them. This is very helpful in setting correct user expectations.

Scroll down the "Actions" section.

Actions: Create new action

An action is how GPT will know "what to invoke" when certain conditions are met. Each of the API calls could become an action. This is where we are going to need the OpenAPI spec YAML file we downloaded earlier. 

  • Authentication: Choose API Key

Authentication: Choose API Key

  • Choose Auth Type: Bearer

Auth Type: Bearer

Get the API Key

Typically every Platform API provides a method of authentication that involves using an API Key. Get the key by signing into that platform. For example, in the case of Decor8 AI, login to https://prod-app.decor8.ai and click on the APIs menu. Here you can create an API Key. Copy-paste the key into the Authentication popup. 

Next, copy-paste the OpenAPI spec's YAML file content under the "Schema" text box.

Copy-paste the OpenAPI spec's YAML file content under "Schema" text box

If the spec is well-formatted, you will see a list of the API calls described in the spec. You can now test them individually. If you click the "Test" button, it will try to invoke the API with the correct input parameters as described in the spec. If it needs to get the value of the input parameter it will ask you.

In the case of Decor8 AI API, let's test the "checkAuthentication" API (which is not needed for the GPT itself). Its successful invocation means everything has been set up correctly between Custom GPT and the target platform (Decor8 AI, in this case).

API authentication was successful

You can test the remaining APIs one by one to ensure GPT has understood the actions correctly. What you will verify is if the GPT asks you for additional input if it was not provided when it performs the action. This is the most interesting part of Custom GPT: it "knows" how to call the API and build the input parameters as per the specification and if any inputs are missing, ask the user. This is how the conversational user interface looks:

Conversational user interface

Here, I asked it to design a room interior for a bedroom with a farmhouse interior design style. This is to invoke one of the API calls which given a photo of a room, room type, and design style can generate a new interior design and return an image.

Here is the original image of an empty room (from the URL mentioned in the screenshot above):

 Image of an empty room

View Farmhouse Bedroom Design chat

If I click on the "View Farmhouse Bedroom Design," we see:

Image of farmhouse design bedroom

Now, you can test other APIs to make sure everything is working as you expect.

Create and Publish the Custom GPT

Make sure to review all the properties for this custom GPT. Here is an example of various configuration properties I set for my custom GPT and I think it's ready to be published.

Decor8 AI Interior Designer screen

Hit the "Create" or ("Update") button on the top right corner and your GPT is live on the internet.

For example, my custom GPT is now live. (You need to sign in to OpenAI to access it. )

Updated room types

Wrapping Up!

Building custom GPT with 3rd party API like Decor8 AI is quite straightforward. You can build your GPT and add best-of-the-breed platforms to it. This will make your GPT more advanced and sophisticated chat bot which can do a lot of helpful activities. 

Hope you enjoyed this tutorial, if you have any questions or feedback, leave them in the comments section.

AI API HTTPS OpenAPI Specification UI

Opinions expressed by DZone contributors are their own.

Related

  • AI-Powered Flashcard Application With Next.js, Clerk, Firebase, Material UI, and LLaMA 3.1
  • Build an AI Chatroom With ChatGPT and ZK by Asking It How!
  • GenAI: From Prompt to Production
  • Grounding Gemini With Google Search and Other Data Sources

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!