Skip to content
  • Why WPGetAPI?
  • Examples
  • Pricing
  • Plugins
    • PRO Plugin
    • API to Posts Plugin
    • OAuth 2.0 Plugin
  • Docs
  • Support
    • Frequently Asked Questions
    • Feature Request
    • Support Ticket
  • account_circle
PRO Plugin
Howdy! How can we help you?
  • Introduction

    • Quick Start
    • Frequently Asked Questions
    • Will this work with my API?
    • Understanding API docs
    • Step by Step Example
  • Setup

    • Setup Page
    • Endpoint Page
    • Parameters - Query String
    • Parameters - Headers
    • Parameters - Body POST
    • Shortcode
    • Template Tag
    • Gutenberg Block
  • Connecting your API

    • API Key in Headers
    • API Key in Query String
    • Authentication & Authorization
  • Output API Data

    • Format API to HTML
    • Format API to HTML Table
    • Format API to Image Gallery
    • Format JSON Data
  • Integrations

    • Send form data to API
    • WPForms to API
    • Gravity Forms to API
    • Contact Form 7 to API
    • WooCommerce to API
    • WooCommerce API Product Sync
    • wpDataTables to API
    • Connect WordPress to OpenAI
    • Connect RapidAPI to WordPress
    • Connect Zoho CRM to WordPress
    • Page Builders (Elementor, DIVI)
    • Formidable Forms to API
    • Elementor Form to API
    • JetFormBuilder to API
    • Fluent Forms to API
    • WS Form to API
    • Ninja Tables to API
    • Easy Digital Downloads(EDD) API Product Sync
    • Ultimate Member Forms to API
  • Tips & Tricks

    • Filters & Action Hooks
    • Code Snippets Plugin
    • Troubleshooting
    • Code Snippets
  • PRO Plugin

    • Installation
    • Actions
    • Tokens
    • Caching
    • Nested data
    • Chaining API calls
    • Dynamic Variables
    • Format API to HTML
    • Call API on user registration
    • Using AJAX to trigger API call
    • Base64 Encoding
    • Licensing
    • Filters & Action Hooks
  • OAuth 2.0 Plugin

    • Installation
    • How it works
    • Grant Type - Client Credentials
    • Grant Type - Authorization Code
    • Licensing
  • API to Posts Plugin

    • Installation
    • Getting Started
    • Multiple Endpoints
    • Mapping Fields
    • Filters & Action Hooks
    • Pagination

Creating your own version of ChatGPT that you can host on your WordPress site is very easy using WPGetAPI. ChatGPT uses the OpenAI API, which is available to anyone.


Preview of our WordPress ChatGPT Form

Here is a preview of what our mini WordPress ChatGPT clone will look like. There is plenty of scope for being able to improve this with styling and the way it is set up. This is just a quick little example.


Requirements

  • A free OpenAI account
  • WPGetAPI installed
  • Our PRO plugin installed

Step 1: Setup API

The first step is to setup the OpenAI API within WPGetAPI using the details as shown in the image below.


Step 2: Setup the endpoint & headers

This is where we configure the data that is sent to OpenAI.

The endpoint we need to use is the Create Chat Completion endpoint. Docs for this endpoint are here: https://platform.openai.com/docs/api-reference/chat/create

The first part of our endpoint is very simple and the settings looks like the below:

Getting your API key

You need to grab your own API key from OpenAI which can be found by logging into your OpenAI account and clicking on your profile at the top right of the page.

Headers

Next we need to include the Authorization header that includes our API key. We can then add the API key with the word Bearer in front of it as shown below.

We also need to include the Content-Type header as shown.


Step 3: Add our prompt

Now in the Body POST Fields, we can choose the model that we want to use and the prompt that we want to use. We also need to set the Encode Body option to JSON encode.

You can see that our prompt is: “Hello! What is 10 plus 10”. You just need to modify this and change it to whatever you want your prompt to be.

That is all we need to setup in our endpoint, so we now hit the Save button.


Step 4: Test the API

After we have saved the endpoint, click on the Test Endpoint button and we see that the response from OpenAI is a success and it is returning the correct answer to our question.

This is cool and all, but we want users to be able to enter their own prompts on the front end of the site.

To do this, we need to use a forms plugin such as WPForms, Gravity Forms or something similar. We will use WPForms in this example as it is free and works really well for this case.


Step 5: Setup our form

We just need to add a new form and a single paragraph field.

Note the ID of our field here is ID #2. This is important as we will need to know this in our next steps so that we can grab the value of this field.

Form confirmation

In our forms confirmation message, we need to copy the shortcode from our endpoint and paste it in here as shown below.

We also add these extra shortcode attributes: format=”html” and keys=”{choices|0|message|content}” which will just grab the content part of the response from OpenAI and will format it as HTML.

Now save the confirmation.


Step 6: Send form data

In our previous endpoint setup, we had just hardcoded our prompt. Now we want to go back to the endpoint and change the prompt to be: [{“role”:”user”,”content”: “(system:post:2)”}]

We are changing the content value to be a Token which grabs the POSTed value from the field with ID #2.

So this is where have hooked up our form to our endpoint.


 

Test it out

All that is left to do is test out the form. You just need to add the form shortcode to your page and then test it out.

On this page
contact_support

Still not sure?

APIs can be daunting and sometimes downright confusing.

But we are here to help! Our support is amazing and we can assist you with any setup required and ensure your API integrations are a success!

Ask Us Anything

Connect your WordPress website to external APIs without writing a single line of code. Send data from WordPress to your API or display data from your API within WordPress.

Support

  • Documentation
  • Support Ticket
  • Refund Policy
  • Contact Us
  • About Us
  • Affiliates

Articles

  • Quick Start Guide
  • WooCommerce Orders to API
  • WooCommerce API Products Sync
  • Contact Form 7 to API
  • WPForms to API
  • Gravity Forms to API
  • WordPress to RapidAPI

WordPress API Plugins

  • Free WPGetAPI Plugin
  • PRO Plugin
  • API to Posts Plugin Plugin
  • OAuth 2.0 Authorization Plugin

© 2025 WPGetAPI. All Rights Reserved.

"*" indicates required fields

Name*
This field is for validation purposes and should be left unchanged.