=AI_TEXT()

The =AI_TEXT() custom formula for Google Sheets is a powerful tool that allows you to generate text using OpenAI's GPT-4 models directly in your spreadsheet.

The =AI_TEXT() custom formula for Google Sheets is a powerful tool that allows you to generate text using OpenAI's GPT-4 models directly in your spreadsheet. This can be used for a variety of purposes, such as generating content, answering questions, and much more.

How to Use

To use the =AI_TEXT() formula, you need to provide the following parameters:

  1. prompt: This is the question or statement that you want the AI to respond to. It can be a simple string of text or a reference to another cell in your spreadsheet.

  2. model: This is the specific GPT-4 model that you want to use to generate the text. You can find a list of available models herearrow-up-right.

  3. maxTokens (optional): This is the maximum number of tokens (words or characters) that you want the AI to generate. The default value is 200.

  4. temperature (optional): This parameter controls the randomness of the AI's output. A higher value (closer to 1) will make the output more random, while a lower value (closer to 0) will make it more focused and deterministic. The default value is 1.

Here is the basic syntax of the formula:

=AI_TEXT(prompt, model, maxTokens, temperature)

Models

Here's a brief overview of the models you can use with the =AI() formula:

  • gpt-3.5-turbo-0301

  • gpt-4-0314

  • gpt-4-32k-0314

  • gpt-4

  • gpt-4-0613

  • gpt-4-32k-0613

  • gpt-3.5-turbo-16k

  • gpt-3.5-turbo-0613

  • gpt-3.5-turbo-16k-0613

  • text-davinci-003

  • text-davinci-002

  • code-davinci-002

Other AI models supported:

Anthropic:

  • Claude 3.5 Sonnet

  • Claude 3 Opus

  • Claude 3 Sonnet

  • Claude 3 Haiku

Cohere:

  • Command R+

  • Command R

  • Command

  • Command Light

Google AI:

  • Gemini 1.5 Pro

  • Gemini 1.5 Flash

  • Gemini 1.0 Pro

For more details of available OpenAI models, please see this pagearrow-up-right.

Examples

Here are a few examples of how you can use the =AI_TEXT() formula:

  1. To ask the AI a question, you can use the formula like this:

This will generate a response from the AI based on the prompt "What is the population of France?" using the "text-davinci-003" model.

  1. You can also reference a cell in your spreadsheet as th

  2. e prompt. For example, if cell A1 contains the question "What is the capital of Australia?", you can use the formula like this:

  1. If you want to generate a longer piece of text, you can increase the maxTokens parameter. For example:

This will generate a story about a brave knight that is up to 500 tokens long.

Important Notes

Before you can use the =AI_TEXT() formula, you need to set your OpenAI API key in the Power Formulas add-on. You can obtain this API key for free on the OpenAI websitearrow-up-right.

If you exceed your daily execution quota under the free plan, you will need to upgrade your plan through the Power Formulas add-on.

Conclusion

The =AI_TEXT() custom formula for Google Sheets is a powerful tool that allows you to leverage the capabilities of OpenAI's GPT-3 models directly in your spreadsheets. With a bit of practice, you can use this formula to generate a wide variety of content and answers to your questions.

Last updated