To write an AI formula in Google Sheets, the most reliable method is a sidebar add-on rather than a custom =AI() function. You write a prompt once, reference your columns by header (for example {{Company}}), and the add-on runs the model on every selected row and writes the result back. This avoids the six-minute Apps Script limit that breaks script-based AI functions on large ranges. Below is the exact method, why custom functions fall short, and what a run costs.
The fastest method, step by step
- Install ReplyLabs from Extensions, Get add-ons, then open it with Extensions, ReplyLabs, Open sidebar.
- Select the column range you want the formula to run on.
- In the AI tab, write your prompt and reference input columns by header, for example "Summarise
{{Notes}}in one sentence." - Check the cost preview for your row count.
- Click Run. Output appears in a new column, one row at a time.
This behaves like a formula in that one instruction fills a whole column, but it runs server-side so it scales to thousands of rows.
Why a custom =AI() function struggles
You can write an Apps Script custom function that calls a model. It works for a handful of cells and then hits walls:
- The six-minute limit. Apps Script kills any execution that runs longer, so a few hundred rows can fail mid-way.
- Quota on external calls.
UrlFetchAppis rate-limited per day, which a real list exhausts quickly. - Recalculation storms. Sheets re-runs custom functions on edit, so the model gets called again and you pay again.
A batched add-on dispatches rows in parallel outside the spreadsheet, so none of these apply.
Make the formula write better output
The "formula" is really a prompt, and a sharper prompt fills the column with sharper text. Three quick wins:
- Pass real facts, not just a name. A prompt that references a scraped detail or a verified field writes output specific to one row instead of generic filler.
- Handle blanks explicitly. Add a line such as "If
{{Notes}}is empty, write a short generic summary" so the model never invents data. - Lock the format. Ask for "one sentence" or "exactly one of: Yes, No" so the result is easy to filter and use in the next step.
What a run costs
ReplyLabs prices AI at the provider's raw cost times 1.25 plus a $0.0025 base fee per succeeded row, and only succeeded rows are charged. The cost preview shows the exact figure before you run. On Pro and Scale you can bring your own AI key and pay only the provider's raw rate. To model a specific run, use the AI cost calculator.
Common questions
Can I reference other cells in the prompt?
Yes. Reference any column by its header in double braces, for example {{First name}} or {{Company}}, and the value for that row is substituted before the model runs.
Is there a real =AI() formula?
ReplyLabs runs from the sidebar rather than a cell formula, on purpose: it sidesteps the Apps Script limits above and lets you preview cost before spending. The full picture is in the AI in Google Sheets guide.
What does an AI prompt mean here?
The instruction template you write once and apply to every row. See the AI prompt definition.