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 totally different Website positioning-related capabilities like key phrase analysis, native Website positioning, 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 online interface is definitely significantly better for some duties), it might assist tackle among the shortcomings of the online interface.
This text will present you tips on how to maximize ChatGPT’s API with particular Website positioning use circumstances.
Methods 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 father or mother firm OpenAI has intensive documentation for utilizing the API.
If you happen to’re seeking to be taught extra about constructing a instrument or interacting straight with the API there’s additionally a superb walk-through right here.
It’s also possible to use AppsScript to question the ChatGPT API in Google Sheets, which we’ll stroll by way of right here step-by-step.
No matter your method, you’ll want to begin by getting an API key.
Getting your ChatGPT API key
After you have an OpenAI account, you possibly can generate your API key both by following this hyperlink whereas logged in or clicking View API keys within the profile dropdown:
Then click on Create new secret key.
Copy the API key you generated.
Connecting the ChatGPT API to Google Sheets
There’s a simple method 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:
You then paste the next code (together with your API key rather than YOUR API KEY):
const SECRET_KEY = "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 = "https://api.openai.com/v1/chat/completions";
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: "software/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:
Then you need to use the next perform format to use a immediate to a cell:
=AI_ChatGPT("YOUR PROMPT HERE")
As Mint factors out in his article, you may also reference a cell if you wish to have a number of cells use prompts that refer again to at least one cell (just like the title or subject of a weblog put up):
Within the instance above, I used easy prompts just like the one pictured, then created a second paragraph for this subject. (We’ll stroll by way of extra particular purposes for the API shortly.)
ChatGPT API pricing
Earlier than you begin leveraging the ChatGPT API for Website positioning 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 higher perceive what the pricing really winds up wanting like, it is advisable 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 it is advisable scale back the variety of tokens for a immediate or response).
A couple of key issues to bear in mind:
- 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 right down to round 4 characters in English.
OpenAI additionally supplied this useful breakdown of how tokens are calculated from textual content:
- 1 token ~= 4 chars in English
- 1 token ~= ¾ phrases
- 100 tokens ~= 75 phrases
Or
- 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,” incorporates 11 tokens.
- OpenAI’s constitution incorporates 476 tokens.
- The transcript of the U.S. Declaration of Independence incorporates 1,695 tokens.
So when you used a brief immediate to generate a 1,500-word article, it could be lower than half a cent.
Get the each day publication search entrepreneurs depend on.
Particular API use circumstances for Website positioning
The API may also help with a variety of the identical Website positioning-related duties because the ChatGPT internet interface, however the two have some vital variations, making some duties higher for one than the opposite.
Understanding that may assist you decide which to make use of for Website positioning duties.
ChatGPT API vs. internet interface
The most important variations embody the next:
Scale and bulk duties
If you wish to combine ChatGPT with an current software or spreadsheet, you may want to make use of the API.
Moreover, the API shall be your pal if you wish to carry out a particular perform utilized throughout a number of situations (e.g., generate meta descriptions for a number of key phrases).
Tremendous-tuning and relationship between prompts
At the moment, ChatGPT’s API doesn’t assist fine-tuning. If you happen to create a number of prompts by way 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 mentioned that these are continuously at the moment ignored by the gpt-3.5-turbo API.
This implies in case you have a activity that requires a number of prompts and for ChatGPT to maintain the context of a whole dialog, you may need to use the online 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 online interface can differ, however typically, the immediate and response are restricted to round 2,048 characters, or 4,096.
So for duties that require extra intensive prompts or extra vital responses, the API shall be a greater possibility.
There are additionally extra choices for structuring prompts and duties in a means that offers you a lengthier mixed output when you’re utilizing code relatively than one thing just like the Google Sheets integration.
Pricing
Once more, the API is priced by utilization (and presents a free trial with $18 value of tokens), and the online interface at the moment presents a free model and a $20/mo. paid model.
Instance ChatGPT API prompts
Let us take a look at particular use circumstances the place you’d need to take into account the API over the online 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 need to use comparable prompts to those who work within the internet interface right here, however when you construction them correctly and lay out your spreadsheet proper, you possibly can take the primary immediate after which shortly apply that to a number of URLs or key phrases:
Be aware that the free plan notably is price restricted, so you will have errors the place the cells day out, through which case it is advisable delete and re-paste:
And as all the time, remember the fact that:
- ChatGPT cannot crawl the online, 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 usually be unsuitable or deceptive and must be edited.
You need to 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 put up outlines
You need to use the online 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 sequence of outlines on totally different subjects, nevertheless, it may be a clunky expertise.
The API is smoother for these duties.
First, you possibly can chunk off a put up you wrote into sections. Then line up the sections and pull your immediate down:
Alternatively, you can have ChatGPT generate a number of outlines that you just then have a author (or writers) fill in:
Then, you can have the API write the content material one part at a time:
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 variety of textual content particular to the subsections of every put up generated.
My expertise is that this helps you keep away from token limits, and even pedestrian prompts just like the one above mixed with having ChatGPT create a top level view will generate higher content material than when you ask the instrument to “write a weblog put up.”
Past that, you possibly can 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 need to add inner hyperlinks for that phrase).
- Feed it statistics or quotes to work into particular sections of the put up. (That is notably useful in case you have a subject that requires up-to-date techniques and statistics, on condition that GPT-3 was not skilled on current knowledge.)
- Tweak your prompts to output the tone and formatting you need (extra on this shortly).
And, as all the time, layer on human enhancing.
FAQs
There are a number of FAQ-related capabilities the API may also help with.
First off, you possibly can generate an inventory of FAQ inquiries to be related to a weblog put up:
Subsequent, you possibly can have the ChatGPT API reply these (once more: proceed with warning in the case of output high quality and accuracy):
Schema
It’s also possible to have ChatGPT generate schemas for you throughout a number of pages.
On this case, we are able to apply FAQ schema to the FAQs it created for us:
Convert content material to HTML
One other cool use case for ChatGPT is to transform textual content to HTML.
First, let’s convert our put up from textual content to HTML:
A couple of issues to notice right here:
- As you possibly can see, the headers in every part have been initially formatted with paragraph tags. I fastened this within the immediate by including, “Format the header of the part as an h2, and some other headlines on this part as an h3.”
- I wasn’t in a position to mix your complete put up (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 whole HTML doc in each cell.
- You might also get some wonky formatting, like extra quotes you did not count on within the output.
As with all points of ChatGPT, hold refining your prompts and all the time test the output.
Add inner hyperlinks
Now that we have now our put up in HTML, we are able to 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 wherever within the HTML we simply generated:
If we have been making a cluster of pages, we might create guidelines particular to every web page and apply them to the related HTML.
This manner, the whole lot we generate is interlinked the best way we would like, the HTML is able to go, and the FAQ schema is added appropriately.
I attempted to create a rule that was a little bit extra sophisticated, asking ChatGPT to hyperlink phrases. Here’s what I added to my immediate:
- “Any time you see the phrases making and snicker inside 5 phrases of one another, create a hyperlink with these two phrases and the entire phrases in between them to standupexperience.com/make-them-laugh.”
Right here is the hyperlink that was added:
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 put up placements, you need to use the ChatGPT API to create a number of outreach templates for you:
If in case you have totally different sorts of templates, get artistic with making use of these prompts throughout totally different outreach targets.
Utilizing the online interface and the API in tandem (a.ok.a., carry your prompts)
Two issues are true:
- The API is healthier for bigger tasks and performs many prompts concurrently.
- The online interface is continuously higher at getting you to a superb output since you possibly can commute with ChatGPT to offer context, assessment the output, present suggestions, and so forth.
One method to get the most effective of each worlds is to create your immediate within the internet interface after which apply it to a number of gadgets by way of the API.
Let us take a look at a particular instance from this put up. 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 possibly can’t give ChatGPT suggestions or ask why the immediate failed.
Enter, immediate era by way of the online!
My typical ChatGPT course of is to:
- Give it chunks of context.
- Examine for understanding.
- Evaluation the output for errors and provides it extra suggestions to attain my desired consequence.
To have the ability to do that for inner linking guidelines, let’s begin with the online interface to scrub up our ChatGPT immediate.
First, I need to give ChatGPT some context. (Bear in mind: ChatGPT does not learn about its personal API!)
I need 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:
If you happen to do not pre-empt it, ChatGPT will repeatedly interrupt you to fireside (continuously 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 would used, and the output I would gotten.
Subsequent, I lastly shared the difficulty with the output:
After which ChatGPT fastened the immediate for me.
Nicely, it wasn’t really fastened.
ChatGPT is relentlessly well mannered even when you’re getting a bit testy, and after I shared the immediate, it analyzed it for me:
The ideas on HTML measurement are good ones, however I used to be nonetheless getting the error:
This time, the immediate labored!
To deal with the max tokens subject, I can go to Apps Script to regulate that quantity:
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
Website positioning purposes for the ChatGPT API go effectively past what’s listed right here.
If you happen to’re looking out for methods to make use of the platform and may get artistic you may discover many extra purposes like:
- Programmatic options: You possibly can transcend Google Sheets to search 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 comparable. What issues do you need to remedy?
- Extra environment friendly or higher workflows: Take inventory of the duties you and your workforce full each day. Are there gadgets that ChatGPT’s API might be able to both let you just do as effectively however extra effectively, or to enhance your work product round?
With the current launch of GPT-4, extra alternatives for leveraging the platform will possible proceed to crop up.
Opinions expressed on this article are these of the visitor creator and never essentially Search Engine Land. Workers authors are listed right here.