SEO guide for the ChatGPT API
ChatGPT has announced its rollout of its API, GPT 3.5 Turbo, on March 1.
ChatGPT’s utility in many SEO-related functions, such as keyword research, local SEO and content, is something I believe in. ChatGPT is a great tool, but I am also acutely aware of its limitations.
Although the API is not a panacea, and the web interface can be much more useful for certain tasks, it can address some of the weaknesses of the web interface.
This article will help you maximize ChatGPT API using specific SEO use cases.
How to use ChatGPT API
Accessing the ChatGPT API is essential in order to leverage it. ChatGPT’s parent company OpenAI provides extensive documentation to assist with the use of the API.
You can find a walkthrough if you want to learn more about building tools or interfacing directly with the API.
AppsScript can also be used to query the ChatGPT API within Google Sheets. We’ll show you how, step-by-step.
No matter what your approach may be, you will need an API key to get started.
Get your ChatGPT API Key
After you create an OpenAI account, you will be able to generate your API key by clicking this link while you are logged in or View API keys from the profile dropdown.
Click Next, create a new secret key.
Copy the API Key you have generated.
Connecting ChatGPT API and Google Sheets
It’s easy to connect ChatGPT and Google Sheets (h/t Keith mint).
First create a Google Sheet. Next, click on Extensions to choose Apps script:
Then paste the following code with your API key in lieu of YOURAPI 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(); }
Save within Apps:
To apply a prompt in a cell, you can use this function format:
=AI_ChatGPT ("YOUR PROMPT HERE")
Mint explains in his article that you can refer to a cell as well. If you need multiple cells, use prompts that point back to one cell (e.g. the title or topic for a blog post).
In the above example, I created a second paragraph to discuss the topic using simple prompts such as the one shown. We’ll soon be discussing more specific API applications.
ChatGPT API Pricing
It is important to fully understand the pricing before you use ChatGPT API to perform SEO tasks.
The price of the gpt3.5-turbo API (the ChatGPTAP) is $0.002 for 1,000 tokens. This is 10x less than the current GPT-3.5 API.
Understanding how tokens work is key to understanding the actual pricing.
ChatGPT API tokens
OpenAI offers a good breakdown as well as a tokenizer tool that can be used to determine how many tokens each text will have and how it is broken down (in the event you need to reduce tokens for prompts or responses).
Here are some key points to remember:
- The API can return by default and a maximum of 4,096 tokens .
- Tokens represent how much text you have to respond to. This is an important factor as long prompts can reduce your response output.
- Text is translated into tokens, and roughly corresponds to 4 characters in English.
OpenAI also provides this useful breakdown of how tokens can be calculated from text.
- 1 token = 4 characters in English
- 1 token ~= 3/4 words
- 100 tokens ~= 75 words
Or
- 1-2 sentences = 30 tokens
- 1 paragraph ~= 100 tokens
- 1,500 words ~= 2048 tokens
This article will give you more context about how tokens stack up.
- Wayne Gretzky’s famous quote “You miss 100% shots you don’t take” contains 11 tokens.
- OpenAI’s charter has 476 tokens.
- The U.S. transcript The Declaration of Independence contains 1,695 tokens.
It would cost less than half of a cent to create a 1,500-word article using a prompt.
SEO specific API uses
Although the API can perform many of the same SEO tasks as ChatGPT’s web interface, there are some important differences that make it easier for some tasks.
This will allow you to choose the right tool for your SEO tasks.
ChatGPT API vs. Web Interface
These are the biggest differences:
Scale and bulk jobs
The API is required to integrate ChatGPT into an existing spreadsheet or application.
If you need to execute a particular function across multiple instances (e.g. generate meta descriptions for multiple keywords), the API is your friend.
Relationship between prompts
ChatGPT’s API currently does not allow fine-tuning. Multiple prompts created through the API won’t form a relationship.
OpenAI allows you to create system messages to apply to multiple prompts or responses. However, OpenAI claims that these messages are often ignored by the gpt 3.5-turbo API.
If you have multiple prompts to complete a task, and ChatGPT needs to know the context of the entire conversation, then you will want to use the web interface.
Character limits
The API token limit is 4,096. This translates into approximately 16,384 characters per interaction, for each prompt or response.
Although the character limit for the web interface is subject to change, generally the prompt and reply are limited to approximately 2,048 characters or 4,096 characters.
The API is a better choice for tasks that require extensive prompts and more complex responses.
If you use code, you have more options to organize prompts and tasks so you get a longer combined output.
Pricing
The API is priced based on usage. It offers a free trial of $18 worth tokens and a $20/mo. web interface. Paid version
ChatGPT API prompts: Example
Let’s take a look at some specific uses cases for which you might want to use the API via the web interface.
Meta descriptions and title tags
ChatGPT is able to generate meta descriptions or title tags at scale. This is an obvious use case for the API.
Similar prompts can be used to the web interface. However, if you organize them correctly and create a spreadsheet, you can quickly apply the prompts to multiple URLs or keywords.
You should note that the free plan is not unlimited. There may be errors when the cells run out. In this case, you will need to delete the cell and re-paste.
Remember, as always:
- ChatGPT cannot crawl the web. It either has no prior knowledge of the URL or it makes assumptions about the URL based upon terms in the URL.
- ChatGPT’s output may sometimes be incorrect or misleading, and should be corrected.
This same format can be used for title tags. This format can also be used for title tags. I’ll soon have an article on ChatGPT that focuses specifically on how to create and update title tag.
Post outlines and longer content
ChatGPT’s web interface allows you to quickly create outline and chunks of content.
It can be difficult to write a long article or to outline a series of topics.
These tasks are easier to accomplish with the API.
You can first cut off the post you have written into sections. Next, line up your sections and draw your prompt.
ChatGPT can also generate outlines which you then send to a writer (or several writers) to fill out.
You could then ask the API to write each section of the content.
You could also take these prompts and load them one at a time across the outline, changing each prompt to correspond with the section. Then, just pull the same formulas across multiple lines and you will have lots of text that is specific to each subsection of each post.
This helps you avoid token limits. I have found that ChatGPT will create better content if ChatGPT asks it to write a blog post.
You can also improve the quality of your content by:
- Ask it to include certain phrases, either because they are needed on the page or to add links to that phrase.
- You can feed it statistics and quotes to make the posts more interesting. This is especially useful if your topic requires the use of up-to-date statistics and tactics, as GPT-3 wasn’t trained with recent data.
- You can modify your prompts to get the tone and formatting that you desire (more details soon).
As always, add human editing.
FAQs
The API has many FAQ-related functions that it can assist with.
You can create a list with FAQ questions that you want to associate with your blog post.
Next, the ChatGPT API can answer them (again, be careful with accuracy and output quality).
Schema
ChatGPT can also generate schemas across multiple pages.
We can use FAQ schema to the FAQs that it has created.
Convert content into HTML
ChatGPT can also be used to convert text into HTML.
Let’s first convert this post from text into HTML.
Here are some things to keep in mind:
- As you can see, each section’s headers were originally formatted using paragraph tags. This was fixed by me adding “Format the heading of the section in an h2 and any other headlines within this section in an h3 to the prompt.”
- It was impossible to combine the whole post, which had around 1100 words, into one cell for HTML conversion. I had to break it up and give specific instructions in my prompt to each cell. This ensured that ChatGPT wouldn’t add formatting to every HTML document.
- There may be some formatting issues, such as extra quotes or other unusual elements in your output.
ChatGPT is a multifaceted platform that allows you to refine your prompts and check the output.
Add internal links
We now have our HTML post, and we can do some fun things with internal linking.
ChatGPT can be told to add links from specific phrases to pages in the HTML that we have just created:
We could create rules for each page in a group of pages and apply them to the relevant HTML.
So everything that we create is interlinked in the way we want. The HTML is ready to use and the FAQ schema can be added.
ChatGPT was asked to link phrases in my rule. I attempted to make it a bit more complex. Here’s what I added to my prompt.
- “Any time you see the words making and laugh within 5 words of each other, create a link with those two words and all of the words in between them to standupexperience.com/make-them-laugh.”
Here’s the link:
It wasn’t what I requested, and it also didn’t connect every stand-up instance as I requested.
I will need to improve my prompts and verify my outputs.
Templates for outreach
ChatGPT API allows you to create multiple outreach templates if you are reaching out to multiple locations for guest post placements or link outreach.
You can use different templates to reach different audiences.
Use the API and the web interface in tandem (also known as “Bring your prompts”)
Two truths are certain:
- The API works better with larger projects, and can perform multiple prompts at once.
- ChatGPT allows you to go back and forth with ChatGPT, giving context, reviewing the output, providing feedback, etc. The web interface is often more effective at getting you to a great output.
Create your prompt in the web interface then apply it via the API.
Let’s take a look at this specific example. The API didn’t work for me when I tried to link my internal links. The API makes it difficult to troubleshoot because ChatGPT feedback is not available.
You can now prompt your web browser!
My ChatGPT process is:
- It needs context.
- Check for understanding.
- To achieve the desired result, I will review the output and provide feedback.
Let’s begin with the chatGPT prompt web interface in order to be able to create internal linking rules.
First, let me give ChatGPT context. ChatGPT does not know anything about its API!
I would like to share information about the API with ChatGPT, the HTML I am using, the prompt I used and the output I received. I will then ask ChatGPT for help in diagnosing the problem and rewriting the prompt.
Let’s find out how it turns out:
ChatGPT will interrupt you repeatedly if you don’t anticipate it. It will fire (often irrelevant) suggestions and answers (like a student who was eager to read but didn’t complete the reading).
I copied and pasted the text from this page in four prompts. These were the HTML I was trying add links to, the Sheets function I used and the output I got.
Then, I shared the issue with my output:
ChatGPT then fixed the prompt.
It wasn’t fixed.
ChatGPT is always polite, even when you get a little testy. When I shared my prompt, it analysed it for me.
Although the suggestions for HTML size are great, I kept getting this error.
The prompt worked this time!
I can adjust the maximum tokens by going to Apps Script.
Or, it is not likely to be an issue if I don’t use Sheets (until the 4096 tokens).
Be creative and search for solutions
The ChatGPT API has many more SEO applications than what is listed here.
You’ll find many other applications that can be used on the platform if you’re looking for creative ways to do so.
- Programmmatic solutions: There are many exciting uses for ChatGPT API that go beyond Google Sheets.
- Combining multiple APIs – Think about how the ChatGPT API could be used in conjunction with APIs such as Ahrefs and Semrush. What problems are you trying to solve?
- Improved workflows: Take a look at the tasks that you and your team complete each day. ChatGPT API might be able help you do the same thing, but faster, or improve your work product.
GPT-4 has just released . This means that there will be more opportunities to leverage the platform.
Search Engine Land first published the post Your SEO Guide to the ChatGPT API.