ChatGPT announced the rollout of its API (GPT 3.5 Turbo) on March 1.
I’m bullish on ChatGPT’s utility for several different SEO-related functions like keyword research, local SEO, content, and link building. Having spent much time using ChatGPT, I’m also painfully aware of its limitations.
While the API won’t be a panacea (and the web interface is actually much better for some tasks), it can help address some of the shortcomings of the web interface.
This article will show you how to maximize ChatGPT’s API with specific SEO use cases.
To leverage the ChatGPT API, you need to be able to access the API in the first place. ChatGPT’s parent company OpenAI has extensive documentation for using the API.
If you’re looking to learn more about building a tool or interacting directly with the API there’s also a good walk-through here.
You can also use AppsScript to query the ChatGPT API in Google Sheets, which we’ll walk through here step by step.
Regardless of your approach, you’ll need to start by getting an API key.
Once you have an OpenAI account, you can generate your API key either by following this link while logged in or clicking View API keys in the profile dropdown:
Then click Create new secret key.
Copy the API key you generated.
There’s a straightforward way to connect ChatGPT to Google Sheets (h/t Keith Mint).
First, create a new Google Sheet, then click on Extensions and choose Apps Script:
You then paste the following code (with your API key in place of YOUR API KEY):
const SECRET_KEY = "YOUR API KEY";
const MAX_TOKENS = 800;
const TEMPERATURE = 0.9;
function AI_ChatGPT(prompt, temperature = 0.4, model = "gpt-3.5-turbo") {
const url = "https://api.openai.com/v1/chat/completions";
const payload = {
model: model,
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: prompt },
],
temperature: TEMPERATURE,
max_tokens: MAX_TOKENS,
};
const options = {
contentType: "application/json",
headers: { Authorization: "Bearer " + SECRET_KEY },
payload: JSON.stringify(payload),
};
const res = JSON.parse(UrlFetchApp.fetch(url, options).getContentText());
return res.choices[0].message.content.trim();
}
Click save within Apps Script:
Then you can use the following function format to apply a prompt to a cell:
=AI_ChatGPT("YOUR PROMPT HERE")
As Mint points out in his article, you can also reference a cell if you want to have multiple cells use prompts that refer back to one cell (like the title or topic of a blog post):
In the example above, I used simple prompts like the one pictured, then created a second paragraph for this topic. (We’ll walk through more specific applications for the API shortly.)
Before you start leveraging the ChatGPT API for SEO tasks, it’s essential to understand the pricing.
The price for the gpt-3.5-turbo API (the ChatGPT API) is $0.002 per 1,000 tokens, which is 10x cheaper than the existing GPT-3.5 API.
To better understand what the pricing actually winds up looking like, you need to understand how tokens work.
OpenAI has a good breakdown and a helpful free tokenizer tool to help you determine how many tokens a specific text will be and how the text is broken down (in case you need to reduce the number of tokens for a prompt or response).
A few key things to keep in mind:
OpenAI also provided this helpful breakdown of how tokens are calculated from text:
Or
To get additional context on how tokens stack up, consider this:
So if you used a short prompt to generate a 1,500-word article, it would be less than half a cent.
Get the daily newsletter search marketers rely on.
The API can help with a lot of the same SEO-related tasks as the ChatGPT web interface, but the two have some significant differences, making some tasks better for one than the other.
Understanding that will help you determine which to use for SEO tasks.
The biggest differences include the following:
Scale and bulk tasks
If you want to integrate ChatGPT with an existing application or spreadsheet, you’ll need to use the API.
Additionally, the API will be your friend if you want to perform a specific function applied across multiple instances (e.g., generate meta descriptions for several keywords).
Fine-tuning and relationship between prompts
Currently, ChatGPT’s API does not support fine-tuning. If you create multiple prompts through the API, they won’t have a relationship.
You can create a system message to apply to multiple prompts and responses, but OpenAI has said that these are frequently currently ignored by the gpt-3.5-turbo API.
This means if you have a task that requires several prompts and for ChatGPT to keep the context of an entire conversation, you’ll want to use the web interface.
Character limits
The API has a token limit of 4,096 which translates to around 16,384 characters per interaction for each prompt and response.
Character limits for the web interface can vary, but generally, the prompt and response are limited to around 2,048 characters, or 4,096.
So for tasks that require more extensive prompts or more significant responses, the API will be a better option.
There are also more options for structuring prompts and tasks in a way that gives you a lengthier combined output if you’re using code rather than something like the Google Sheets integration.
Pricing
Again, the API is priced by usage (and offers a free trial with $18 worth of tokens), and the web interface currently offers a free version and a $20/mo. paid version.
Let’s look at specific use cases where you’d want to consider the API over the web interface.
An obvious use case where the API makes sense is having ChatGPT generate title tags or meta descriptions at scale.
You can use similar prompts to those that work in the web interface here, but if you structure them properly and lay out your spreadsheet right, you can take the first prompt and then quickly apply that to several URLs or keywords:
Note that the free plan particularly is rate limited, so you may have errors where the cells time out, in which case you need to delete and re-paste:
And as always, keep in mind that:
You can use this same format for title tags. (I’ll have an article focusing specifically on using ChatGPT to generate and update title tags coming out soon).
You can use the web interface in ChatGPT to create chunks of content and outlines pretty easily.
If you want to make a longer article or if you’re going to create a series of outlines on different topics, however, it can be a clunky experience.
The API is smoother for these tasks.
First, you can chunk off a post you wrote into sections. Then line up the sections and pull your prompt down:
Alternatively, you could have ChatGPT generate several outlines that you then have a writer (or writers) fill in:
Then, you could have the API write the content one section at a time:
Again, here you could take these prompts, load them one by one across the outline (changing each prompt for the appropriate section), and then just pull the same formulas across multiple outlines and have a lot of text specific to the subsections of each post generated.
My experience is that this helps you steer clear of token limits, and even pedestrian prompts like the one above combined with having ChatGPT create an outline will generate better content than if you ask the tool to “write a blog post.”
Beyond that, you can further improve content quality by doing things like:
And, as always, layer on human editing.
There are multiple FAQ-related functions the API can help with.
First off, you can generate a list of FAQ questions to be associated with a blog post:
Next, you can have the ChatGPT API answer these (again: proceed with caution when it comes to output quality and accuracy):
You can also have ChatGPT generate schemas for you across multiple pages.
In this case, we can apply FAQ schema to the FAQs it created for us:
Another cool use case for ChatGPT is to convert text to HTML.
First, let’s convert our post from text to HTML:
A few things to note here:
As with all aspects of ChatGPT, keep refining your prompts and always check the output.
Now that we have our post in HTML, we can start to do some cool things with internal linking.
We can tell ChatGPT to add internal links from specific phrases to specific pages anywhere in the HTML we just generated:
If we were creating a cluster of pages, we could create rules specific to each page and apply them to the relevant HTML.
This way, everything we generate is interlinked the way we want, the HTML is ready to go, and the FAQ schema is added appropriately.
I tried to create a rule that was a little more complicated, asking ChatGPT to hyperlink phrases. Here is what I added to my prompt:
Here is the link that was added:
That’s not what I asked for, and also, it didn’t link every instance of stand-up as I asked it to.
I’ll need to refine my prompts and check my outputs.
If you’re reaching out to multiple places for link outreach or guest post placements, you can use the ChatGPT API to create multiple outreach templates for you:
If you have different kinds of templates, get creative with applying these prompts across different outreach targets.
Two things are true:
One way to get the best of both worlds is to create your prompt in the web interface and then apply it to multiple items via the API.
Let’s look at a specific example from this post. My internal linking prompt didn’t work via the API. It’s challenging to troubleshoot via the API because you can’t give ChatGPT feedback or ask why the prompt failed.
Enter, prompt generation via the web!
My typical ChatGPT process is to:
To be able to do this for internal linking rules, let’s start with the web interface to clean up our ChatGPT prompt.
First, I want to give ChatGPT some context. (Remember: ChatGPT doesn’t know about its own API!)
I want to give it information about the API, share the HTML I’m starting with, share the prompt I used, and share the output I got and then ask ChatGPT to diagnose the issue and rewrite the prompt for me.
Let’s see how it goes:
If you don’t pre-empt it, ChatGPT will repeatedly interrupt you to fire (frequently irrelevant) answers and suggestions (like an eager student who didn’t do the reading).
I copied and pasted the text from this page in four prompts, the HTML I was trying to add links to, the full Sheets function I’d used, and the output I’d gotten.
Next, I finally shared the issue with the output:
And then ChatGPT fixed the prompt for me.
Well, it wasn’t actually fixed.
ChatGPT is relentlessly polite even if you’re getting a bit testy, and when I shared the prompt, it analyzed it for me:
The suggestions on HTML size are good ones, but I was still getting the error:
This time, the prompt worked!
To address the max tokens issue, I can go to Apps Script to adjust that number:
Or obviously, if I’m not using Sheets, it’s not likely to be an issue (until I hit the 4096 tokens).
SEO applications for the ChatGPT API go well beyond what’s listed here.
If you’re on the lookout for ways to use the platform and can get creative you’ll find many more applications like:
With the recent release of GPT-4, more opportunities for leveraging the platform will likely continue to crop up.
Opinions expressed in this article are those of the guest author and not necessarily Search Engine Land. Staff authors are listed here.
Google announced and emailed advertisers that they are changing the functionality of Google Ads accounts…
About 45 minutes before OpenAI's announcement of GPT-4o, Google posted on X a demo of…
Google may be showing more review stars in the mobile search results, according to some…
Bloomberg reports that Google has downgraded/lowered the search rankings of Deepfake porn sites. Bloomberg wrote,…
Once your online store is up and running, you'll want to see how it performs…
In February, we caught Google testing a new search filter named "Web Results." Well, last…
This website uses cookies.
Leave a Comment