Latest Post

White Home Publishes Nationwide Aeronautics Science & Know-how Priorities What GPT Entrepreneurs Have to Know

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

I’m bullish on ChatGPT’s utility for a number of completely different Search engine optimization-related capabilities like key phrase analysis, native Search engine optimization, content material, and hyperlink constructing. Having spent a lot time utilizing ChatGPT, I’m additionally painfully conscious of its limitations.

Whereas the API received’t be a panacea (and the net interface is definitely significantly better for some duties), it could possibly assist handle a number of the shortcomings of the net interface.

This text will present you the right way to maximize ChatGPT’s API with particular Search engine optimization use circumstances.

The best way to use the ChatGPT API

To leverage the ChatGPT API, you want to have the ability to entry the API within the first place. ChatGPT’s mother or father firm OpenAI has in depth documentation for utilizing the API.

If you happen to’re trying to be taught extra about constructing a instrument or interacting immediately with the API there’s additionally an excellent walk-through right here.

You may as well use AppsScript to question the ChatGPT API in Google Sheets, which we’ll stroll by means of right here step-by-step.

No matter your method, you’ll want to start out by getting an API key.

Getting your ChatGPT API key

Upon getting an OpenAI account, you may generate your API key both by following this hyperlink whereas 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

Copy the API key you generated.

ChatGPT - API key generated

Connecting the ChatGPT API to Google Sheets

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

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

ChatGPT API - Google Sheets extension

You then paste the next code (along with your API key instead of YOUR API KEY):

const MAX_TOKENS = 800;
const TEMPERATURE = 0.9;

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

Click on save inside Apps Script:

ChatGPT API - Apps Script

Then you need to use the next perform format to use a immediate to a cell:


ChatGPT Google Sheet prompt formula

As Mint factors out in his article, you can too reference a cell if you wish to have a number of cells use prompts that refer again to 1 cell (just like the title or matter of a weblog submit):

ChatGPT - Google Sheet prompt formula with multiple cells

Within the instance above, I used easy prompts just like the one pictured, then created a second paragraph for this matter. (We’ll stroll by means of extra particular functions for the API shortly.) 

ChatGPT API pricing

Earlier than you begin leveraging the ChatGPT API for Search engine optimization duties, it’s important to know the pricing.

The value for the gpt-3.5-turbo API (the ChatGPT API) is $0.002 per 1,000 tokens, which is 10x cheaper than the prevailing GPT-3.5 API.

To raised perceive what the pricing really winds up trying like, you must perceive how tokens work.

ChatGPT API tokens

OpenAI has a good breakdown and a useful free tokenizer instrument that will help you decide what number of tokens a particular textual content shall be and the way the textual content is damaged down (in case you must cut back the variety of tokens for a immediate or response).

A number of key issues to remember:

  • By default, the API can return a most of 4,096 tokens.
  • Tokens are a illustration of how a lot textual content your immediate and response are. It is a key issue, as longer prompts can shorten your response output.
  • Textual content is translated into tokens and roughly breaks all the way down to round 4 characters in English.

OpenAI additionally supplied this beneficial breakdown of how 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 extra context on how tokens stack up, take into account this:

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

So in the event you used a brief immediate to generate a 1,500-word article, it might be lower than half a cent.

Get the every day publication search entrepreneurs depend on.

Particular API use circumstances for Search engine optimization

The API may also help with a number of the identical Search engine optimization-related duties because the ChatGPT net interface, however the two have some important variations, making some duties higher for one than the opposite.

Understanding that may assist you to decide which to make use of for Search engine optimization duties.

ChatGPT API vs. net interface

The largest variations embody the next:

Scale and bulk duties

If you wish to combine ChatGPT with an present utility or spreadsheet, you will want to make use of the API. 

Moreover, the API shall be your good friend if you wish to carry out a particular perform utilized throughout a number of cases (e.g., generate meta descriptions for a number of key phrases).

Superb-tuning and relationship between prompts

At the moment, ChatGPT’s API doesn’t help fine-tuning. If you happen to create a number of prompts by means of the API, they will not have a relationship. 

You possibly can create a system message to use to a number of prompts and responses, however OpenAI has stated that these are steadily at present ignored by the gpt-3.5-turbo API. 

This implies in case you have a job that requires a number of prompts and for ChatGPT to maintain the context of a complete dialog, you will wish to use the net interface.

Character limits

The API has a token restrict of 4,096 which interprets to round 16,384 characters per interplay for every immediate and response

Character limits for the net interface can range, however usually, the immediate and response are restricted to round 2,048 characters, or 4,096. 

So for duties that require extra in depth prompts or extra important responses, the API shall be a greater choice. 

There are additionally extra choices for structuring prompts and duties in a means that provides you a lengthier mixed output in the event you’re utilizing code relatively than one thing just like the Google Sheets integration.


Once more, the API is priced by utilization (and presents a free trial with $18 value of tokens), and the net interface at present presents a free model and a $20/mo. paid model. 

Instance ChatGPT API prompts

Let’s take a look at particular use circumstances the place you’d wish to take into account the API over the net interface.

Title tags and meta descriptions

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

You should use related prompts to those who work within the net interface right here, however in the event you construction them correctly and lay out your spreadsheet proper, you may take the primary immediate after which shortly apply that to a number of URLs or key phrases: 

ChatGPT API - Title tags and meta descriptions

Notice that the free plan notably is fee restricted, so you’ll have errors the place the cells outing, wherein case you must delete and re-paste:

ChatGPT API - Google Sheets errors

And as at all times, understand that:

  • ChatGPT cannot crawl the net, so it is both utilizing prior data of a URL from the coaching interval or an assumption in regards to the URL primarily based on phrases within the URL to generate ideas
  • ChatGPT’s output can typically be improper or deceptive and must be edited.

You should use this identical format for title tags. (I am going to have an article focusing particularly on utilizing ChatGPT to generate and replace title tags popping out quickly).

Longer content material and submit outlines

You should use the net interface in ChatGPT to create chunks of content material and descriptions fairly simply.

If you wish to make an extended article or if you are going to create a collection of outlines on completely different subjects, nonetheless, it may be a clunky expertise.

The API is smoother for these duties.

First, you may chunk off a submit you wrote into sections. Then line up the sections and pull your immediate down:

ChatGPT API - longer content and post outlines

Alternatively, you can have ChatGPT generate a number of outlines that you just then have a author (or writers) fill in:

ChatGPT API - article outlines

Then, you can have the API write the content material one part at a time:

ChatGPT API - write article sections

Once more, right here you can take these prompts, load them one after the other throughout the define (altering every immediate for the suitable part), after which simply pull the identical formulation throughout a number of outlines and have a number of textual content particular to the subsections of every submit generated.

My expertise is that this helps you avoid token limits, and even pedestrian prompts just like the one above mixed with having ChatGPT create an overview will generate higher content material than in the event you ask the instrument to “write a weblog submit.” 

Past that, you may additional enhance content material high quality by doing issues like:

  • Ask it to incorporate particular phrases (both since you need them on the web page otherwise you wish to add inner hyperlinks for that phrase).
  • Feed it statistics or quotes to work into particular sections of the submit. (That is notably useful in case you have a subject that requires up-to-date ways and statistics, provided that GPT-3 was not skilled on latest information.)
  • Tweak your prompts to output the tone and formatting you need (extra on this shortly).

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


There are a number of FAQ-related capabilities the API may also help with.

First off, you may generate an inventory of FAQ inquiries to be related to a weblog submit:


Subsequent, you may have the ChatGPT API reply these (once more: proceed with warning on the subject of output high quality and accuracy):

ChatGPT API - FAQs - answers


You may as well have ChatGPT generate schemas for you throughout a number of pages. 

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

ChatGPT API - Schema

Convert content material to HTML

One 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 number of issues to notice right here:

  • As you may see, the headers in every part had been initially formatted with paragraph tags. I fastened this within the immediate by including, “Format the header of the part as an h2, and another headlines on this part as an h3.”
  • I wasn’t in a position to mix the complete submit (which was round 1100 phrases) into one cell to be transformed to HTML, so I needed to chunk it off and gave particular directions in my immediate for every cell to ensure ChatGPT did not layer within the formatting for a complete HTML doc in each cell.
  • You may additionally get some wonky formatting, like extra quotes you did not count on within the output. 

As with all facets of ChatGPT, preserve refining your prompts and at all times test the output.

Now that now we have our submit in HTML, we will begin to do some cool issues with inner linking.

We are able to inform ChatGPT so as to add inner hyperlinks from particular phrases to particular pages anyplace within the HTML we simply generated:

ChatGPT API - Add internal links

If we had been making a cluster of pages, we may create guidelines particular to every web page and apply them to the related HTML.

This fashion, every little thing we generate is interlinked the best way we wish, the HTML is able to go, and the FAQ schema is added appropriately.

I attempted to create a rule that was just a little extra difficult, asking ChatGPT to hyperlink phrases. Here’s what I added to my immediate:

  • “Any time you see the phrases making and snort inside 5 phrases of one another, create a hyperlink with these two phrases and the entire phrases in between them to”

Right here is the hyperlink that was added:

ChatGPT API - Wrong hyperlinks

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

I am going to must refine my prompts and test my outputs.

Outreach templates

If you happen to’re reaching out to a number of locations for hyperlink outreach or visitor submit placements, you need to use the ChatGPT API to create a number of outreach templates for you:

ChatGPT API - Outreach templates

In case you have completely different sorts of templates, get artistic with making use of these prompts throughout completely different outreach targets.

Utilizing the net interface and the API in tandem (a.ok.a., carry your prompts)

Two issues are true:

  • The API is best for bigger tasks and performs many prompts concurrently.
  • The online interface is steadily higher at getting you to a wonderful output since you may trip with ChatGPT to present context, evaluation the output, present suggestions, and many others.

One strategy to get the very best of each worlds is to create your immediate within the net interface after which apply it to a number of objects by way of the API.

Let’s take a look at a particular instance from this submit. My inner linking immediate did not work by way of the API. It is difficult to troubleshoot by way of the API as a result of you may’t give ChatGPT suggestions or ask why the immediate failed.

Enter, immediate technology by way of the net!

My typical ChatGPT course of is to: 

  • Give it chunks of context.
  • Examine for understanding. 
  • Evaluate the output for errors and provides it extra suggestions to realize my desired end result.

To have the ability to do that for inner linking guidelines, let’s begin with the net interface to scrub up our ChatGPT immediate.

First, I wish to give ChatGPT some context. (Keep in mind: ChatGPT would not learn about its personal API!) 

I wish to give it details about the API, share the HTML I am beginning with, share the immediate I used, and share the output I received after which ask ChatGPT to diagnose the difficulty and rewrite the immediate for me.

Let’s examine the way it goes:

ChatGPT web - Prompt creation

If you happen to do not pre-empt it, ChatGPT will repeatedly interrupt you to fireside (steadily irrelevant) solutions and ideas (like an keen scholar who did not do the studying).

I copied and pasted the textual content from this web page in 4 prompts, the HTML I used to be attempting so as to add hyperlinks to, the complete Sheets perform I might used, and the output I might gotten.

Subsequent, I lastly shared the difficulty with the output:

ChatGPT web - Prompt creation for Google Sheets

After which ChatGPT fastened the immediate for me.

ChatGPT web - Fixed prompt Google Sheets

Effectively, it wasn’t really fastened.

ChatGPT web - Prompt syntax error

ChatGPT is relentlessly well mannered even in the event you’re getting a bit testy, and once I shared the immediate, it analyzed it for me:

ChatGPT Web Prompt Feedback 800x557

The ideas on HTML dimension are good ones, however I used to be nonetheless getting the error:

ChatGPT web - Google Sheet max character limit

This time, the immediate labored!

To deal with the max tokens difficulty, I can go to Apps Script to regulate that quantity:

ChatGPT API - Google Sheet fix character limit

Or clearly, if I am not utilizing Sheets, it isn’t more likely to be a difficulty (till I hit the 4096 tokens).

Get artistic and search for options

Search engine optimization functions for the ChatGPT API go properly past what’s listed right here. 

If you happen to’re looking out for methods to make use of the platform and might get artistic you will discover many extra functions like:

  • Programmatic options: You possibly can transcend Google Sheets to seek out thrilling and scalable makes use of for the ChatGPT API.
  • Combining a number of APIs: Take into consideration the way you may be capable to use the ChatGPT API in unison with APIs like Google Search Console, Ahrefs, Semrush or related. What issues do you wish to resolve? 
  • Extra environment friendly or higher workflows: Take inventory of the duties you and your staff full every day. Are there objects that ChatGPT’s API might be able to both let you do exactly as properly however extra effectively, or to enhance your work product round?

With the latest launch of GPT-4, extra alternatives for leveraging the platform will seemingly proceed to crop up.

Opinions expressed on this article are these of the visitor creator and never essentially Search Engine Land. Employees authors are listed right here.

Supply hyperlink

Leave a Reply

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