GPT for Sheets reference

This is a reference of all available functions in GPT for Sheets. If you are looking for usage examples, click here.

GPT function

The simplest function to start using GPT in Sheets. Outputs the result in a single cell.

Video preview

How to use

syntax
=GPT(prompt, [value], [temperature], [max_tokens], [model])
copy/paste example
=GPT("Write a tagline for an ice cream shop.")
⚠️ localization
in some locales, you might need to use ";" to separate parameters instead of ","
output
a response to your prompt in a single cell

Parameters

Parameter
Definition
prompt (cannot be empty)
Text, cell or range containing the prompt. Examples: • "Write a tagline for an ice cream shop." • A1 • A1:C3
(optional) value
Text, cell or range you want your prompt to apply to
(optional) temperature, max_tokens, model
temperature is a number between 0 and 1. Use it to control creativity. max_tokens is a number between 0 and model limit. Decrease if your request times out. Increase if your response is cut. Learn more below

Usage examples

GPT_LIST / GPT_HLIST function

Like GPT, but outputs the results in a column. Very practical when the output is a list.

Use GPT_LIST to return options listed vertically.

Use GPT_HLIST to return options listed horizontally.

Video preview

How to use

syntax
=GPT_LIST(prompt, [value], [temperature], [max_tokens], [model])
copy/paste example
=GPT_LIST("Give me 5 good short ads about spreadsheets.")
⚠️ localization
in some locales, you might need to use ";" to separate parameters instead of ","
output
as many responses to your prompt as you asked, one response per cell

Parameters

Parameter
Definition
prompt (cannot be empty)
Text, cell or range containing the prompt. Examples: • "Write a tagline for an ice cream shop." • A1 • A1:C3
(optional) value
Text, cell or range you want your prompt to apply to
(optional) temperature, max_tokens, model
temperature is a number between 0 and 1. Use it to control creativity. max_tokens is a number between 0 and model limit. Decrease if your request times out. Increase if your response is cut. Learn more below

Usage examples

GPT_SPLIT / GPT_HSPLIT function

Splits text semantically, such as by section, paragraph, sentence, customer…

Use GPT_SPLIT to return outputs listed vertically.

Use GPT_HSPLIT to return outputs listed horizontally.

How to use

syntax
=GPT_SPLIT(text, split_by, [temperature], [max_tokens], [model])
copy/paste example
=GPT_SPLIT("Hello! How are you? Have you heard of GPT for Sheets?", "sentences")
⚠️ localization
in some locales, you might need to use ";" to separate parameters instead of ","
output
input text is split as requested, one element per cell

Parameters

Parameter
Definition
text (cannot be empty)
Input text to split
split_by (cannot be empty)
How to split the text. Examples: - sections - paragraphs - sentences - punctuation
(optional) temperature, max_tokens, model
temperature is a number between 0 and 1. Use it to control creativity. max_tokens is a number between 0 and model limit. Decrease if your request times out. Increase if your response is cut. Learn more below

GPT_FILL function

Magically fill or clean a range from a few examples.

Video preview

How to use

syntax
=GPT_FILL(examples, [inputs], [temperature], [max_tokens], [model])
⚠️ localization
in some locales, you might need to use ";" to separate parameters instead of ","
output
the empty part of the range will be filled based on the examples provided

Parameters

Parameter
Definition
examples
Range containing complete examples that GPT should learn from
(optional) inputs
Range containing incomplete data that GPT should complete from the examples
(optional) temperature, max_tokens, model
temperature is a number between 0 and 1. Use it to control creativity. max_tokens is a number between 0 and model limit. Decrease if your request times out. Increase if your response is cut. Learn more below

Usage examples

GPT_TABLE function

Like GPT, but outputs the results in a table. Very practical when the output is a table.

Video preview

How to use

syntax
=GPT_TABLE(prompt, [head], [inputs], [temperature], [max_tokens], [model])
copy/paste example
=GPT_TABLE("top 10 most eaten fruits and their nutrition data")
⚠️ localization
in some locales, you might need to use ";" to separate parameters instead of ","
output
the response to your prompt in the shape of a table

Parameters

Parameter
Definition
prompt (cannot be empty)
Text, cell or range containing the prompt. Examples: • "top 10 most eaten fruits and their nutrition data" • A1 • A1:C3
(optional) head
Range containing at least one row. the first row should be headers, the following rows can be used to specify examples If left empty, headers will be generated automatically.
(optional) inputs
Range containing partial rows to complete with GPT_TABLE
(optional) temperature, max_tokens, model
temperature is a number between 0 and 1. Use it to control creativity. max_tokens is a number between 0 and model limit. Decrease if your request times out. Increase if your response is cut. Learn more below

GPT_MAP function

Map the values of two columns by similarity.

Video preview

How to use

syntax
=GPT_MAP(search_keys, range, [confidence], [stats], [top_k])
copy/paste example
=GPT_MAP(A1:A10,B1:B4)
⚠️ localization
in some locales, you might need to use ";" to separate parameters instead of ","
output
a column of the best matches to each value in the range

Parameters

Parameter
Definition
search_keys (cannot be empty)
The values that you want to look for in the range
range (cannot be empty)
The range in which to look for values that are similar to search keys
confidence (optional)
Set a similarity threshold: only values with a superior similarity score are mapped. Must be comprised between 0 and 1
stats (optional)
"true" to display similarity scores
top_k (optional)
Number of matching values to return per search_key (default: 1 - only the best match)
(optional) temperature, max_tokens, model
temperature is a number between 0 and 1. Use it to control creativity. max_tokens is a number between 0 and model limit. Decrease if your request times out. Increase if your response is cut. Learn more below

GPT_FORMAT function

Format dates, currencies, addresses, names, etc. Fix capitalization. And so much more.

Video preview

How to use

syntax
=GPT_FORMAT(input, target_format, [source_format], [temperature], [max_tokens], [model])
copy/paste example
=GPT_FORMAT("14 February 71", "iso")
⚠️ localization
in some locales, you might need to use ";" to separate parameters instead of ","
output
the converted input in a single cell unless it is converted a table, which outputs a table

Parameters

Parameter
Definition
input (cannot be empty)
Text, cell or range containing the input to be converted. Examples: • "14 February 1971” • A1 • A1:C3
target_format (cannot be empty)
Target format for the input. Examples: “iso”, “currency iso”, “international phone number”, “lowercase/uppercase/camelcase/snake case/title case/sentence case”…
(optional) source_format
Source format of the input. Optional, but including it can yield better results.
(optional) temperature, max_tokens, model
temperature is a number between 0 and 1. Use it to control creativity. max_tokens is a number between 0 and model limit. Decrease if your request times out. Increase if your response is cut. Learn more below

GPT_EDIT function

Applies the given task to the given text. The default ask is to fix grammar and spelling.

Video preview

How to use

syntax
=GPT_EDIT(text, [task], [temperature], [max_tokens], [model])
copy/paste example
=GPT_EDIT("For sum reezon thoose nunsberz arnt addin up")
⚠️ localization
in some locales, you might need to use ";" to separate parameters instead of ","
output
the edited text in a single cell

Parameters

Parameter
Definition
text (cannot be empty)
Text, cell or range to be edited. Examples: • "For sum reezon thoose nunsberz arnt addin up" • A1 • A1:C3
(optional) task
Text, cell or range specifying how the text should be edited. Defaults to fixing grammar and spelling. Other examples: • “Make it funnier” • “Make it shorter” • “Make it sound formal” • “Add an ending”
(optional) temperature, max_tokens, model
temperature is a number between 0 and 1. Use it to control creativity. max_tokens is a number between 0 and model limit. Decrease if your request times out. Increase if your response is cut. Learn more below

GPT_TAG function

Applies user-defined tags to a given text.

Video preview

How to use

syntax
=GPT_TAG(text,[tags], [top_k], [examples], temperature], [max_tokens], [model])
copy/paste example
=GPT_TAG("I love chocolate", "food, positive, negative")
⚠️ localization
in some locales, you might need to use ";" to separate parameters instead of ","
output
the applicable tags as csv in a single cell

Parameters

Parameter
Definition
text (cannot be empty)
Text, cell or range. Examples: • "I love chocolate" • A1 • A1:C3
(optional) tags
Comma-separated tags or range of tags applicable. If left empty, GPT_TAG will automatically come up with the tags
(optional) top_k
Maximum number of tags to return
(optional) examples
A table of examples in two columns. The first column should contain the inputs and the second column should contain the outputs.
(optional) temperature, max_tokens, model
temperature is a number between 0 and 1. Use it to control creativity. max_tokens is a number between 0 and model limit. Decrease if your request times out. Increase if your response is cut. Learn more below

GPT_CLASSIFY function

Classifies a given text into a single category.

This function can use the text-embedding-ada-002 model for stricter application of categories and cheaper cost.

Video preview

How to use

syntax
=GPT_CLASSIFY(text, categories, [examples], temperature], [max_tokens], [model])
copy/paste example
=GPT_CLASSIFY("banana", "fruit, vegetable")
⚠️ localization
in some locales, you might need to use ";" to separate parameters instead of ","
output
the best applicable category

Parameters

Parameter
Definition
text (cannot be empty)
Text, cell or range. Examples: • "banana" • A1 • A1:C3
categories (cannot be empty)
Comma-separated categories or range of categories to choose from. Only the most relevant category will be returned.
(optional) examples
A table of examples in two columns. The first column should contain the inputs and the second column should contain the outputs.
(optional) temperature, max_tokens, model
temperature is a number between 0 and 1. Use it to control creativity. max_tokens is a number between 0 and model limit. Decrease if your request times out. Increase if your response is cut. Learn more below

GPT_EXTRACT function

Extracts data (like email addresses or company names) from a text. Outputs as comma-separated values.

Video preview

How to use

syntax
=GPT_EXTRACT(text, to_extract, [temperature], [max_tokens], [model])
copy/paste example
=GPT_EXTRACT("I worked 12 years at Amazon.com at Apple", "companies")
⚠️ localization
in some locales, you might need to use ";" to separate parameters instead of ","
output
the extracted entities as comma-separated values in a single cell

Parameters

Parameter
Definition
text (cannot be empty)
Text, cell or range to extract data from. Examples: • "I worked 5 years at Amazon.com and then 3 years at Apple" • A1 • A1:C3
to_extract (cannot be empty)
Text, cell or horizontal range specifying what you want to extract. Examples: • "email addresses" • B3:E3
(optional) temperature, max_tokens, model
temperature is a number between 0 and 1. Use it to control creativity. max_tokens is a number between 0 and model limit. Decrease if your request times out. Increase if your response is cut. Learn more below

GPT_SUMMARIZE function

Summarizes text according to a given format (three sentences by default).

Video preview

How to use

syntax
=GPT_SUMMARIZE(text, [format], [temperature], [max_tokens], [model])
copy/paste example
=GPT_SUMMARIZE("some long content here")
⚠️ localization
in some locales, you might need to use ";" to separate parameters instead of ","
output
a summary in the requested format in a single cell

Parameters

Parameter
Definition
text (cannot be empty)
Text, cell or range to summarize. Examples: • "Some long content" • A1 • A1:C3
(optional) format
Format of the summary. Examples: • "key takeaways" • “action items” • “two paragraphs” • “100 words” • “tweets”
(optional) temperature, max_tokens, model
temperature is a number between 0 and 1. Use it to control creativity. max_tokens is a number between 0 and model limit. Decrease if your request times out. Increase if your response is cut. Learn more below

GPT_TRANSLATE function

Translates text from one language into another. Works better if you specify the source language.

Video preview

How to use

syntax
=GPT_TRANSLATE(text, target_language, [source_language], [instructions],[temperature], [maxTokens], [model])
copy/paste example
=GPT_TRANSLATE("Cool off with our delicious treats!", "spanish")
⚠️ localization
in some locales, you might need to use ";" to separate parameters instead of ","
output
the requested translation in a single cell

Parameters

Parameter
Definition
text (cannot be empty)
Text, cell or range to translate. Examples: • "Cool off with our delicious treats!" • A1 • A1:C3
target_language (cannot be empty)
Language of the output. Examples: “spanish”, “chinese”, “french”
(optional) source_language
Language of the input. Example: “english”
(optional) instructions
Additional instructions for the translation. Can include a dictionary of translations.
(optional) temperature, max_tokens, model
temperature is a number between 0 and 1. Use it to control creativity. max_tokens is a number between 0 and model limit. Decrease if your request times out. Increase if your response is cut. Learn more below

GPT_CONVERT function

Converts from one format to another. For instance json to table, or xml to json.

How to use

syntax
=GPT_CONVERT(input, target_format, [source_format], [temperature], [max_tokens], [model])
copy/paste example
=GPT_CONVERT("<ul><li><p>Name: Joe</p><p>Age: 27</p></li><li><p>Name: Jane</p><p>Age: 28</p></li></ul>", "json")
⚠️ localization
in some locales, you might need to use ";" to separate parameters instead of ","
output
the converted input in a single cell unless it is converted a table, which outputs a table

Parameters

Parameter
Definition
input (cannot be empty)
Text, cell or range containing the input to be converted. Examples: • "<ul><li><p>Name: Joe</p><p>Age: 27</p></li><li><p>Name: Jane</p><p>Age: 28</p></li></ul>" • A1 • A1:C3
target_format (cannot be empty)
Target format for the input. Examples: “json”, “html”, “markdown”, “json-ld”, “table”, “csv”
(optional) source_format
Source format of the input. Optional, but including it can yield better results. Examples: “json”, “html”, “markdown”, “json-ld”, “table”, “csv”
(optional) temperature, max_tokens, model
temperature is a number between 0 and 1. Use it to control creativity. max_tokens is a number between 0 and model limit. Decrease if your request times out. Increase if your response is cut. Learn more below

GPT_CODE function

Generates code to accomplish the given task. Output is a function.

How to use

syntax
=GPT_CODE(task, [language], [temperature], [max_tokens], [model])
copy/paste example
=GPT_CODE("concatenate two strings", "Javascript")
⚠️ localization
in some locales, you might need to use ";" to separate parameters instead of ","
output
code that implements task in a single cell

Parameters

Parameter
Definition
task (cannot be empty)
Text, cell or range specifying what the generated code should do. Examples: • "check that a number n is odd" • “compute a sha256 hash” • “bubble sort”
(optional) language
Programming language the code needs to be written in.
(optional) temperature, max_tokens, model
temperature is a number between 0 and 1. Use it to control creativity. max_tokens is a number between 0 and model limit. Decrease if your request times out. Increase if your response is cut. Learn more below

temperature, max_tokens and model

These parameters are the same for all GPT functions. They are always optional.

Parameter
Definition
(optional) temperature
Number between 0 and 1 that governs the creativity of GPT: • 0 makes GPT strictly follow the prompt (default) • 0.5 makes GPT slightly creative • 1 makes GPT very creative in some locales, you might need to use "0,5" instead of "0.5"
(optional) max_tokens
The maximum response size in tokens. Must be a round number greater than 0 and lower than the model limit. Defaults to 4096 - prompt tokens for gpt-3.5-turbo. Defaults to 500 for other base models to prevent time out risk. Learn more about tokens here
(optional) model
All text OpenAI base and fine-tuned models are available by their name. The most popular base models are the following: • gpt-3.5-turbo: (default) Most capable GPT-3.5 model that backs the official ChatGPT interface. Can do any task the other models can do, faster and with higher quality. 10x cheaper than text-davinci-003. • gpt-4 or gpt-4-32k: (if you have access) Latest and most powerful OpenAI model with broader general knowledge than other models and advanced reasoning capabilities. Up to 60x more expensive and much slower than gpt-3.5-turbo. • text-davinci-003: Very capable GPT-3 model. Can do any task the other models can do, often with higher quality, longer output and better instruction-following. Also supports inserting completions within text. • text-curie-001: Less capable, but faster and lower cost than Davinci. • text-babbage-001: Less capable, but faster and lower cost than Curie. • text-ada-001: Least capable, but fastest and lowest cost of all. GPT_CLASSIFY can use text-embedding-ada-002

GPT_CREATE_PROMPT helper function

Like CONCATENATE, but inserts spaces and newlines automatically. Helps you create a prompt from scattered, disjointed cells and ranges. You can then use that prompt in GPT functions. This function doesn’t call GPT and thus doesn’t incur any cost.

How to use

syntax
=GPT_CREATE_PROMPT(arg1, [arg2], [arg3], [...argn])
copy/paste example
=GPT_CREATE_PROMPT(A1:B1, A2, C3:D5, E1:E6)
⚠️ localization
in some locales, you might need to use ";" to separate parameters instead of ","
output
a prompt ready to use in GPT, GPT_LIST or GPT_TABLE

Parameters

Parameter
Definition
arg1 (cannot be empty)
Cell or range to concatenate • A1 • A1:C3
(optional) arg2 - argn
Cell or range to concatenate • A2 • G2:H4