Your SEO guide to the ChatGPT API

ChatGPT announced the rollout of its API (GPT 3.5 Turbo) on March 1. 

I’m bullish on ChatGPT’s utility for several other Search engine optimization-related purposes like keyword research, local SEO, content, and link building. Having spent a lot time the use of ChatGPT, I’m additionally painfully acutely aware of its boundaries.

Whilst the API gained’t be a panacea (and the internet interface is in truth a lot better for some duties), it will probably assist deal with one of the shortcomings of the internet interface.

This text will display you maximize ChatGPT’s API with explicit Search engine optimization use instances.

Learn how to use the ChatGPT API

To leverage the ChatGPT API, you want so that you can get right of entry to the API within the first position. ChatGPT’s mum or dad corporate OpenAI has in depth documentation for the use of the API.

If you happen to’re having a look to be told extra about construction a device or interacting at once with the API there’s additionally a just right walk-through here.

You’ll be able to additionally use AppsScript to question the ChatGPT API in Google Sheets, which we’ll stroll via right here step-by-step.

Irrespective of your method, you’ll want to get started by means of getting an API key.

Getting your ChatGPT API key

After you have an OpenAI account, you’ll be able to generate your API key both by means of following this link whilst logged in or clicking View API keys within the profile dropdown:

ChatGPT - View API keys

Then click on Create new secret key.

ChatGPT - Create new secret key

Reproduction the API key you generated.

ChatGPT - API key generated

Connecting the ChatGPT API to Google Sheets

There’s a simple solution to attach ChatGPT to Google Sheets (h/t Keith Mint).

First, create a brand new Google Sheet, then click on on Extensions and make a selection Apps Script:

ChatGPT API - Google Sheets extension

Then you paste the next code (together with your API key rather than YOUR API KEY):

const MAX_TOKENS = 800;
const TEMPERATURE = 0.9;

serve as AI_ChatGPT(instructed, temperature = 0.4, type = "gpt-3.5-turbo") {
  const url = "";
  const payload = {
    type: type,
    messages: [
      { role: "system", content: "You are a helpful assistant." },
      { role: "user", content: prompt },
    temperature: TEMPERATURE,
    max_tokens: MAX_TOKENS,
  const choices = {
    contentType: "software/json",
    headers: { Authorization: "Bearer " + SECRET_KEY },
    payload: JSON.stringify(payload),
  const res = JSON.parse(UrlFetchApp.fetch(url, choices).getContentText());
  go back res.alternatives[0].message.content material.trim();

Click on save inside Apps Script:

ChatGPT API - Apps Script

Then you’ll be able to use the next serve as layout to use a instructed to a cellular:


ChatGPT Google Sheet prompt formula

As Mint issues out in his article, you’ll be able to additionally reference a cellular if you wish to have a couple of cells use activates that refer again to 1 cellular (just like the identify or matter of a weblog submit):

ChatGPT - Google Sheet prompt formula with multiple cells

Within the instance above, I used easy activates like the only pictured, then created a 2d paragraph for this matter. (We’ll stroll via extra explicit packages for the API in a while.) 

ChatGPT API pricing

Sooner than you get started leveraging the ChatGPT API for Search engine optimization duties, it’s very important to know the pricing.

The fee for the gpt-3.5-turbo API (the ChatGPT API) is $0.002 in step with 1,000 tokens, which is 10x less expensive than the prevailing GPT-3.5 API.

To raised perceive what the pricing in truth finally ends up having a look like, you want to know how tokens paintings.

ChatGPT API tokens

OpenAI has a good breakdown and a useful unfastened tokenizer tool that will help you decide what number of tokens a selected textual content will likely be and the way the textual content is damaged down (in case you want to scale back the collection of tokens for a instructed or reaction).

A couple of key issues to remember:

  • By means of default, the API can go back a most of four,096 tokens.
  • Tokens are a illustration of the way a lot textual content your instructed and reaction are. This can be a key issue, as longer activates can shorten your reaction output.
  • Textual content is translated into tokens and more or less breaks all the way down to round 4 characters in English.

OpenAI additionally equipped this beneficial breakdown of the way tokens are calculated from textual content:

  • 1 token ~= 4 chars in English
  • 1 token ~= ¾ phrases
  • 100 tokens ~= 75 phrases


  • 1-2 sentence ~= 30 tokens
  • 1 paragraph ~= 100 tokens
  • 1,500 phrases ~= 2048 tokens

To get further context on how tokens stack up, imagine this:

  • Wayne Gretzky’s quote, “You leave out 100% of the pictures you don’t take,” comprises 11 tokens.
  • OpenAI’s charter comprises 476 tokens.
  • The transcript of the U.S. Declaration of Independence comprises 1,695 tokens.

So when you used a brief instructed to generate a 1,500-word article, it could be not up to part a cent.

Get the day-to-day e-newsletter seek entrepreneurs depend on.

Explicit API use instances for Search engine optimization

The API can assist with a large number of the similar Search engine optimization-related duties because the ChatGPT internet interface, however the two have some vital variations, making some duties higher for one than the opposite.

Figuring out to help you decide which to make use of for Search engine optimization duties.

ChatGPT API vs. internet interface

The most important variations come with the next:

Scale and bulk duties

If you wish to combine ChatGPT with an present software or spreadsheet, you’ll be able to want to use the API. 

Moreover, the API will likely be your buddy if you wish to carry out a selected serve as implemented throughout a couple of circumstances (e.g., generate meta descriptions for a number of key phrases).

Superb-tuning and dating between activates

These days, ChatGPT’s API does no longer enhance fine-tuning. If you happen to create a couple of activates during the API, they may not have a dating. 

You’ll be able to create a device message to use to a couple of activates and responses, however OpenAI has mentioned that those are incessantly these days left out by means of the gpt-3.5-turbo API. 

This implies when you’ve got a job that calls for a number of activates and for ChatGPT to stay the context of a complete dialog, it would be best to use the internet interface.

Personality limits

The API has a token restrict of four,096 which interprets to round 16,384 characters in step with interplay for each and every instructed and reaction

Personality limits for the internet interface can range, however usually, the instructed and reaction are restricted to round 2,048 characters, or 4,096. 

So for duties that require extra in depth activates or extra vital responses, the API will likely be a better choice. 

There also are extra choices for structuring activates and duties in some way that offers you a lengthier mixed output in case you are the use of code quite than one thing just like the Google Sheets integration.


Once more, the API is priced by means of utilization (and provides a unfastened trial with $18 value of tokens), and the internet interface these days provides a unfastened model and a $20/mo. paid model. 

Instance ChatGPT API activates

Let us take a look at explicit use instances the place you would wish to imagine the API over the internet interface.

Identify tags and meta descriptions

An evident use case the place the API is smart is having ChatGPT generate identify tags or meta descriptions at scale.

You’ll be able to use equivalent activates to people who paintings within the internet interface right here, however when you construction them correctly and lay out your spreadsheet proper, you’ll be able to take the primary instructed after which briefly observe that to a number of URLs or key phrases: 

ChatGPT API - Title tags and meta descriptions

Notice that the unfastened plan in particular is charge restricted, so you will have mistakes the place the cells day trip, by which case you want to delete and re-paste:

ChatGPT API - Google Sheets errors

And as at all times, needless to say:

  • ChatGPT can not move slowly the internet, so it is both the use of prior wisdom of a URL from the learning length or an assumption concerning the URL in line with phrases within the URL to generate ideas
  • ChatGPT’s output can regularly be unsuitable or deceptive and must be edited.

You’ll be able to use this similar layout for identify tags. (I’m going to have an editorial focusing in particular on the use of ChatGPT to generate and replace identify tags popping out quickly).

Longer content material and submit outlines

You’ll be able to use the internet interface in ChatGPT to create chunks of content material and descriptions lovely simply.

If you wish to make an extended article or if you are going to create a chain of outlines on other subjects, alternatively, it may be a clunky enjoy.

The API is smoother for those duties.

First, you’ll be able to chew off a submit you wrote into sections. Then line up the sections and pull your instructed down:

ChatGPT API - longer content and post outlines

However, it’s essential have ChatGPT generate a number of outlines that then you definately have a author (or writers) fill in:

ChatGPT API - article outlines

Then, it’s essential have the API write the content material one phase at a time:

ChatGPT API - write article sections

Once more, right here it’s essential take those activates, load them one at a time around the define (converting each and every instructed for the right phase), after which simply pull the similar formulation throughout a couple of outlines and feature a large number of textual content explicit to the subsections of each and every submit generated.

My enjoy is this is helping you avoid token limits, or even pedestrian activates like the only above mixed with having ChatGPT create an summary will generate higher content material than when you ask the software to “write a weblog submit.” 

Past that, you’ll be able to additional reinforce content material high quality by means of doing such things as:

  • Ask it to incorporate explicit words (both as a result of you wish to have them at the web page or you wish to have so as to add interior hyperlinks for that word).
  • Feed it statistics or quotes to paintings into explicit sections of the submit. (That is in particular useful when you’ve got a subject matter that calls for up-to-date techniques and statistics, for the reason that GPT-3 used to be no longer educated on fresh information.)
  • Tweak your activates to output the tone and formatting you wish to have (extra in this in a while).

And, as at all times, layer on human enhancing.


There are a couple of FAQ-related purposes the API can assist with.

First off, you’ll be able to generate a listing of FAQ inquiries to be related to a weblog submit:


Subsequent, you’ll be able to have the ChatGPT API resolution those (once more: continue with warning in the case of output high quality and accuracy):

ChatGPT API - FAQs - answers


You’ll be able to even have ChatGPT generate schemas for you throughout a couple of pages. 

On this case, we will be able to observe FAQ schema to the FAQs it created for us:

ChatGPT API - Schema

Convert content material to HTML

Some other cool use case for ChatGPT is to transform textual content to HTML. 

First, let’s convert our submit from textual content to HTML:

ChatGPT API - Convert content to HTML

A couple of issues to notice right here:

  • As you’ll be able to see, the headers in each and every phase had been to begin with formatted with paragraph tags. I fastened this within the instructed by means of including, “Structure the header of the phase as an h2, and another headlines on this phase as an h3.”
  • I wasn’t ready to mix all the submit (which used to be round 1100 phrases) into one cellular to be transformed to HTML, so I needed to chew it off and gave explicit directions in my instructed for each and every cellular to ensure ChatGPT did not layer within the formatting for a whole HTML record in each cellular.
  • You might also get some wonky formatting, like further quotes you did not be expecting within the output. 

As with every facets of ChatGPT, stay refining your activates and at all times test the output.

Now that we have got our submit in HTML, we will be able to begin to perform a little cool issues with interior linking.

We will inform ChatGPT so as to add interior hyperlinks from explicit words to precise pages any place within the HTML we simply generated:

ChatGPT API - Add internal links

If we had been making a cluster of pages, shall we create laws explicit to each and every web page and observe them to the related HTML.

This manner, the entirety we generate is interlinked the best way we would like, the HTML is able to move, and the FAQ schema is added correctly.

I attempted to create a rule that used to be slightly extra sophisticated, asking ChatGPT to link words. Here’s what I added to my instructed:

  • “Any time you notice the phrases making and snigger inside 5 phrases of one another, create a hyperlink with the ones two phrases and all the phrases in between them to”

This is the hyperlink that used to be added:

ChatGPT API - Wrong hyperlinks

That is not what I requested for, and likewise, it did not hyperlink each example of stand-up as I requested it to.

I’m going to want to refine my activates and test my outputs.

Outreach templates

If you are attaining out to a couple of puts for hyperlink outreach or visitor submit placements, you’ll be able to use the ChatGPT API to create a couple of outreach templates for you:

ChatGPT API - Outreach templates

You probably have other types of templates, get inventive with making use of those activates throughout other outreach objectives.

The use of the internet interface and the API in tandem (a.okay.a., deliver your activates)

Two issues are true:

  • The API is healthier for better tasks and plays many activates concurrently.
  • The internet interface is incessantly higher at getting you to a very good output since you’ll be able to move backward and forward with ChatGPT to present context, evaluate the output, supply comments, and so forth.

One solution to get the most efficient of each worlds is to create your instructed within the internet interface after which use it on a couple of pieces by way of the API.

Let us take a look at a selected instance from this submit. My interior linking instructed did not paintings by way of the API. It is difficult to troubleshoot by way of the API as a result of you’ll be able to’t give ChatGPT comments or ask why the instructed failed.

Input, instructed technology by way of the internet!

My conventional ChatGPT procedure is to: 

  • Give it chunks of context.
  • Test for working out. 
  • Evaluation the output for mistakes and provides it further comments to succeed in my desired outcome.

So to do that for interior linking laws, let’s get started with the internet interface to wash up our ChatGPT instructed.

First, I wish to give ChatGPT some context. (Consider: ChatGPT does not find out about its personal API!) 

I wish to give it details about the API, percentage the HTML I am beginning with, percentage the instructed I used, and percentage the output I were given after which ask ChatGPT to diagnose the problem and rewrite the instructed for me.

Let’s have a look at the way it is going:

ChatGPT web - Prompt creation

If you do not pre-empt it, ChatGPT will again and again interrupt you to fireside (incessantly beside the point) solutions and recommendations (like an keen scholar who did not do the studying).

I copied and pasted the textual content from this page in 4 activates, the HTML I used to be making an attempt so as to add hyperlinks to, the entire Sheets serve as I would used, and the output I would gotten.

Subsequent, I in any case shared the problem with the output:

ChatGPT web - Prompt creation for Google Sheets

After which ChatGPT fastened the instructed for me.

ChatGPT web - Fixed prompt Google Sheets

Smartly, it wasn’t in truth fastened.

ChatGPT web - Prompt syntax error

ChatGPT is relentlessly well mannered despite the fact that you are getting a little testy, and after I shared the instructed, it analyzed it for me:

ChatGPT Web Prompt Feedback 800x557

The ideas on HTML dimension are just right ones, however I used to be nonetheless getting the mistake:

ChatGPT web - Google Sheet max character limit

This time, the instructed labored!

To handle the max tokens factor, I will move to Apps Script to regulate that quantity:

ChatGPT API - Google Sheet fix character limit

Or clearly, if I am not the use of Sheets, it is not prone to be a topic (till I hit the 4096 tokens).

Get inventive and search for answers

Search engine optimization packages for the ChatGPT API move way past what is indexed right here. 

If you are in search of tactics to make use of the platform and will get inventive you’ll be able to to find many extra packages like:

  • Programmatic answers: You’ll be able to transcend Google Sheets to search out thrilling and scalable makes use of for the ChatGPT API.
  • Combining a couple of APIs: Take into consideration the way you could possibly use the ChatGPT API in unison with APIs like Google Seek Console, Ahrefs, Semrush or equivalent. What issues do you wish to have to resolve? 
  • Extra environment friendly or higher workflows: Take inventory of the duties you and your group entire day-to-day. Are there pieces that ChatGPT’s API might be able to both help you do exactly as smartly however extra successfully, or to reinforce your paintings product round?

With the hot release of GPT-4, extra alternatives for leveraging the platform will most probably proceed to crop up.

Reviews expressed on this article are the ones of the visitor writer and no longer essentially Seek Engine Land. Personnel authors are indexed here.

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *