# Connecting ChatGPT to Google Sheets for Product Descriptions
For 200 rows and a non-developer, I recommend **Google Apps Script with the OpenAI API**. It's free (beyond OpenAI usage costs), gives you a custom `=GPT()` formula, and takes ~10 minutes to set up.
---
## Setup
### 1. Get your OpenAI API key
- Go to https://platform.openai.com/api-keys
- Click **Create new secret key**, copy it (starts with `sk-...`)
- Add a small amount of credit at **Billing → Add payment method** ($5 is plenty for 200 rows — actual cost ~$0.10 with `gpt-4o-mini`)
### 2. Open Apps Script in your sheet
- In your Google Sheet: **Extensions → Apps Script**
- Delete any default code in the editor
### 3. Paste the code below
- Paste the script (next section), **replace `YOUR_API_KEY_HERE`** with your key
- Click the 💾 **Save** icon, name the project "GPT Rewriter"
- Close Apps Script and return to your sheet
---
## Code
```javascript
/**
* Rewrites a product description into a punchy 2-sentence version.
* Usage in a cell: =GPT(A2)
*/
function GPT(prompt) {
const API_KEY = "YOUR_API_KEY_HERE"; // paste your key here
const url = "https://api.openai.com/v1/chat/completions";
const payload = {
model: "gpt-4o-mini", // cheap + fast; good for bulk rewrites
messages: [
{ role: "system", content: "Rewrite product descriptions into a punchy, engaging 2-sentence version. Return only the rewrite." },
{ role: "user", content: String(prompt) }
],
temperature: 0.7
};
const options = {
method: "post",
contentType: "application/json",
headers: { Authorization: "Bearer " + API_KEY },
payload: JSON.stringify(payload),
muteHttpExceptions: true
};
const response = UrlFetchApp.fetch(url, options);
const data = JSON.parse(response.getContentText());
if (data.error) return "Error: " + data.error.message;
return data.choices[0].message.content.trim();
}
```
---
## Usage
1. Assume original descriptions are in **column A** (A2:A201).
2. In **B2**, type: `=GPT(A2)`
3. Press Enter. First run, Google will ask to **authorize** — click **Review permissions → Advanced → Go to GPT Rewriter (unsafe) → Allow**. (It's "unsafe" only because it's your own script.)
4. Drag the B2 fill handle down to B201. Cells will show `Loading...` then fill in.
5. **Important:** Once done, copy column B → **Paste Special → Values only**. This locks in the text so it doesn't re-run and cost you again.
---
## Troubleshooting
- **`Error: Rate limit`** — Fill ~50 rows at a time instead of all 200. Free-tier API keys have low rate limits; paid accounts are fine.
- **`#ERROR!` or blank cells** — Select the cell and press **Delete**, then re-enter the formula. Apps Script custom functions sometimes time out after 30s.
- **Inconsistent tone** — Edit the `system` prompt (e.g., "Use a playful tone with emojis" or "Keep under 25 words per sentence").
- **Cost control** — Stick with `gpt-4o-mini` (~$0.0005 per rewrite). Avoid `gpt-4o` for bulk jobs unless you need higher quality.
- **Key safety** — Never share the sheet's Apps Script with others; your API key is inside it.
That's it — you'll have 200 punchy descriptions in under 10 minutes. 🚀
How to Use ChatGPT Inside Google Sheets for Automation
Tested prompts for connect chatgpt to google sheets compared across 5 leading AI models.
If you searched for 'connect chatgpt to google sheets', you probably have a spreadsheet full of data you want to enrich, classify, clean, or summarize, and you don't want to copy-paste into ChatGPT row by row. The good news: you can call GPT directly from a cell like any other formula, using =GPT(prompt) or a custom Apps Script function that hits the OpenAI API.
There are three realistic paths. The fastest is installing a prebuilt add-on like GPT for Sheets and Docs or SheetAI, which gives you =GPT() functions in minutes. The most flexible is writing your own Apps Script function with your OpenAI API key, so you control the model, temperature, and cost. The no-code path is piping Sheets through Zapier or Make to ChatGPT and back, which suits scheduled workflows more than live formulas.
This page shows the exact prompt we tested across GPT-4o, Claude, Gemini, and a cheaper model, along with the output quality and cost per 1,000 rows. Use it to decide which setup and which model fit your job before you install anything.
When to use this
Use ChatGPT inside Google Sheets when you have repetitive text tasks across many rows and the logic is too fuzzy for a regular formula but too small to justify a full app. It shines for classification, extraction, rewriting, and enrichment at the row level, especially when a human would otherwise read each cell and type a short answer.
- Categorizing customer support tickets or survey responses into tags
- Extracting company names, job titles, or locations from messy text fields
- Generating product descriptions or ad copy from a list of SKUs and features
- Translating or summarizing columns of user reviews
- Scoring leads or emails based on intent signals in a notes column
When this format breaks down
- Spreadsheets over ~5,000 rows run live: you will hit rate limits and rack up API cost. Batch with Apps Script and cache results instead.
- Tasks that need deterministic math or exact lookups. Use native formulas, QUERY, or VLOOKUP. GPT will occasionally hallucinate numbers.
- Anything involving regulated or confidential data (PHI, payment data, internal financials) unless you are on an enterprise plan with a signed DPA.
- Real-time dashboards that recalculate on every edit. Each recalc is a paid API call, and Sheets will trigger thousands of them.
The prompt we tested
You are an expert in connecting ChatGPT to Google Sheets and building AI-powered spreadsheet automations. Based on the user's scenario below, provide a clear, step-by-step guide covering: (1) the best integration method for their use case (OpenAI API with Apps Script, GPT for Sheets add-on, Zapier/Make, or third-party extensions), (2) exact setup instructions including API key retrieval, installation steps, and authentication, (3) a working code snippet or formula example they can copy-paste, and (4) tips for handling errors, rate limits, and costs. Format the response with numbered steps and clear section headers (Setup, Code/Formula, Usage, Troubleshooting). Include at least one copy-ready code block (Apps Script) or formula example with inline comments. Keep the tone practical and beginner-friendly, and keep total length under 500 words. User's scenario: I run a small e-commerce store and have a Google Sheet with about 200 product descriptions that are too long. I want to use ChatGPT inside the sheet to automatically rewrite each description into a punchy 2-sentence version in column B. I'm not a developer but I can follow instructions.
Model comparison
| Model | Quality | Cost | Latency | Tokens |
|---|---|---|---|---|
| Claude Opus 4.7 | 9 | $0.1059 | 19.7s | 398 / 1333 |
| Claude Haiku 4.5 | 9 | $0.0060 | 9.5s | 279 / 1154 |
| GPT-5.4 | Not run yet | |||
| Gemini 2.5 Pro | 8 | $0.0027 | 17.4s | 258 / 469 |
| Grok 4.1 Fast Reasoning | 9 | $0.0004 | 14.0s | 396 / 716 |
Outputs
# ChatGPT Product Description Shortener for Google Sheets
## Best Integration Method
**Recommendation: OpenAI API + Google Apps Script**
This is ideal for your use case because:
- Cost-effective (you pay per API call, ~$0.001 per description)
- Works directly in Sheets with no add-ons
- Handles 200 descriptions reliably
- No monthly subscription fees
---
## Setup Instructions
### Step 1: Get Your OpenAI API Key
1. Go to [platform.openai.com](https://platform.openai.com)
2. Sign up or log in
3. Click **API keys** (left sidebar) → **Create new secret key**
4. Copy and **save it somewhere safe** (you'll need it in 10 minutes)
5. Set a usage limit in **Billing** → **Usage limits** (~$20 recommended)
### Step 2: Open Apps Script in Google Sheets
1. Create or open your Google Sheet with products in column A
2. Go to **Extensions** → **Apps Script**
3. Delete any default code and paste the code block below
### Step 3: Add Your API Key
1. In Apps Script, go to **Project Settings** (gear icon)
2. Enable **Apps Script API**
3. Return to the editor and add your key to line 2 of the script
---
## Code Block (Copy-Paste Ready)
```javascript
// ⚠️ REPLACE 'YOUR_API_KEY_HERE' with your actual key from OpenAI
const OPENAI_API_KEY = 'YOUR_API_KEY_HERE';
function shortenDescription(productDescription) {
if (!productDescription || productDescription.trim() === '') {
return 'Error: Empty description';
}
const url = 'https://api.openai.com/v1/chat/completions';
const payload = {
model: 'gpt-3.5-turbo',
messages: [
{
role: 'system',
content: 'You are a copywriter. Rewrite product descriptions into exactly 2 punchy sentences (under 30 words total). Be compelling and focus on benefits.'
},
{
role: 'user',
content: productDescription
}
],
max_tokens: 50,
temperature: 0.7
};
const options = {
method: 'post',
headers: {
'Authorization': 'Bearer ' + OPENAI_API_KEY,
'Content-Type': 'application/json'
},
payload: JSON.stringify(payload),
muteHttpExceptions: true
};
try {
const response = UrlFetchApp.fetch(url, options);
const result = JSON.parse(response.getContentText());
if (result.error) {
return 'Error: ' + result.error.message;
}
return result.choices[0].message.content.trim();
} catch (error) {
return 'Error: API call failed';
}
}
// Run this to shorten ALL descriptions in column A, output to column B
function processAllDescriptions() {
const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A:A');
const values = range.getValues();
for (let i = 0; i < values.length; i++) {
if (values[i][0] && i > 0) { // Skip header row
const shortened = shortenDescription(values[i][0]);
sheet.getRange(i + 1, 2).setValue(shortened); // Write to column B
Utilities.sleep(300); // Avoid rate limits (300ms delay)
}
}
SpreadsheetApp.getUi().alert('✓ Done! Check column B.');
}
```
---
## Usage
1. **First test**: In column B, cell B2, enter formula: `=shortenDescription(A2)` and press Enter
2. **Process all**: Click **Run** button and select `processAllDescriptions`
3. Monitor **Execution log** (bottom of Apps Script editor) for errors
---
## Troubleshooting
| Issue | Solution |
|-------|----------|
| "Invalid API key" | Verify key copied correctly; check it's not expired |
| Rate limit errors | Already built in (300ms delays). Increase to 500ms if needed |
| Timeout errors | Split 200 descriptions into batches of 50 |
| Blank outputs | Check original description isn't empty; increase `max_tokens` to 60 |
**Estimated cost**: 200 descriptions × ~$0.0005 = **~$0.10 total**
Of course. For your goal of batch-rewriting 200 product descriptions, the most direct and cost-effective method is using the **OpenAI API with Google Apps Script**. This avoids third-party subscription fees and gives you a reusable tool right inside your sheet.
Here is your step-by-step guide.
### 1. Setup
First, you need to get an OpenAI API key and open the script editor in your Google Sheet.
1. **Get OpenAI API Key:**
* Go to [platform.openai.com](https://platform.openai.com/) and log in or create an account.
* Go to the API Keys section (click your profile icon in the top-right).
* Click "**Create new secret key**". Name it something like "GoogleSheets" and copy the key immediately. **You will not be able to see it again.**
* You must also set up billing by adding a payment method under the "Billing" section. You'll only be charged for what you use, which will be very low for this task (likely less than $0.20).
2. **Open Apps Script Editor:**
* In your Google Sheet, click **Extensions** > **Apps Script**.
* A new browser tab will open with a code editor. Delete any placeholder code in the `Code.gs` file.
### 2. Code
Copy the entire code block below and paste it into the Apps Script editor.
```javascript
// Replace "YOUR_API_KEY" with the key you copied from OpenAI.
const SECRET_KEY = "YOUR_API_KEY";
/**
* Rewrites a long product description into a punchy 2-sentence version.
*
* @param {string} long_description The text from the source cell to rewrite.
* @return The rewritten description from ChatGPT.
* @customfunction
*/
function GENERATE_DESCRIPTION(long_description) {
// Check if the input is empty to avoid unnecessary API calls.
if (!long_description) {
return "Input cell is empty.";
}
// The API endpoint for chat models
### Best Method: OpenAI API + Google Apps Script
Perfect for batch-rewriting 200 descriptions in one click—no per-cell formulas, low cost (~$0.05 total with GPT-4o-mini), fully customizable.
### Setup
1. Get OpenAI API key: Visit [platform.openai.com/api-keys](https://platform.openai.com/api-keys), sign up/log in, click "Create new secret key". Copy it (starts with `sk-`).
2. Open your Sheet > **Extensions > Apps Script**.
3. Delete default code, paste the script below. Replace `YOUR_API_KEY_HERE` with your key.
4. Save project (name it "Product Rewriter"). Click **Run** > authorize permissions (review scopes: Sheets, external requests).
```javascript
function rewriteDescriptions() {
const sheet = SpreadsheetApp.getActiveSheet();
const data = sheet.getRange('A2:A201').getValues(); // Assumes descriptions in A2:A201
const apiKey = 'YOUR_API_KEY_HERE'; // Paste your key here
const url = 'https://api.openai.com/v1/chat/completions';
for (let i = 0; i < data.length; i++) {
const desc = data[i][0];
if (!desc) continue; // Skip empty cells
const prompt = `Rewrite this product description into a punchy 2-sentence version:\n\n${desc}`;
const payload = {
model: 'gpt-4o-mini', // Cheap & fast
messages: [{role: 'user', content: prompt}],
max_tokens: 100
};
const options = {
method: 'POST',
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
},
payload: JSON.stringify(payload)
};
try {
const response = UrlFetchApp.fetch(url, options);
const json = JSON.parse(response.getContentText());
const result = json.choices[0].message.content.trim();
sheet.getRange(i + 2, 2).setValue(result); // Writes to B column
Utilities.sleep(100); // Avoid rate limits
} catch (error) {
console.log(`Row ${i+2} error: ${error}`);
sheet.getRange(i + 2, 2).setValue('Error');
}
}
}
```
### Usage
1. In Apps Script, select `rewriteDescriptions` > **Run**. It processes A2:A201 → B2:B201 automatically.
2. Refresh Sheet. Add **Insert > Drawing > Save and Close** for a button: Right-click drawing > **Assign script > rewriteDescriptions**.
### Troubleshooting
- **Auth error**: Re-authorize in Apps Script (clock icon > latest run > authorize).
- **Rate limits**: If throttled, increase `sleep(100)` to 500ms or run in batches (edit range to A2:A50).
- **Costs**: Monitor at [platform.openai.com/usage](https://platform.openai.com/usage); ~$0.00015/1K tokens.
- **Quota exceeded**: Use cheaper `gpt-4o-mini` or check OpenAI billing.
- Logs: **View > Logs** for errors. Test on 1 row first.
Total time: ~2-5 mins for 200 rows. Done! (298 words)
What makes these work
-
01Force a strict output format
Tell the model exactly what to return: 'Return only the label' or 'Return JSON with keys x, y, z'. Without this, you get full sentences that break downstream formulas. Add 'No explanation' when you only need the value.
-
02Cache results with a helper column
Wrap your GPT call so it only runs when the input changes. One pattern: paste values after generation, or use an Apps Script that writes results to a column and skips rows already filled. This stops runaway API costs on recalc.
-
03Pick the right model per column
Use gpt-4o-mini or gpt-3.5 for classification and extraction at scale, and reserve gpt-4o for writing tasks where quality matters. The cost difference across 10,000 rows can be 20x for near-identical output on simple tasks.
-
04Batch rows in a single prompt
Instead of 1,000 calls for 1,000 rows, send 20 rows per call and ask for a numbered list back. This cuts latency and cost dramatically. Split the response with SPLIT() or parse JSON in Apps Script.
More example scenarios
=GPT("Classify this support ticket into one of: Billing, Bug, Feature Request, Account, Other. Return only the label. Ticket: " & A2) where A2 contains: 'Hi, I was charged twice for my May subscription and need a refund on one of the charges. Order #4421.'
Billing
=GPT("From the job post below, extract Company, Role, Location, Remote (yes/no) as a JSON object. Post: " & B2) where B2 is a pasted LinkedIn job description of 300 words for a remote Senior Product Manager role at Stripe in Dublin.
{"Company":"Stripe","Role":"Senior Product Manager","Location":"Dublin, Ireland","Remote":"yes"}
=GPT("Write a 40-word product description highlighting benefits, not specs. Product: " & A2 & ". Features: " & B2) where A2='Merino Wool Crew Socks' and B2='80% merino, cushioned heel, 3-pack, unisex, sizes 6-12'.
Keep your feet warm, dry, and blister-free all day. Our merino crew socks wick sweat, cushion every step, and resist odor so you can wear them twice. Unisex sizing 6-12, sold in packs of three.
=GPT("Return sentiment (Positive/Neutral/Negative) and the main reason in 5 words. Format: sentiment | reason. Review: " & C2) where C2 is 'Loved the food but waited 45 minutes for a table even with a reservation.'
Negative | long wait despite reservation
=GPT("Return the canonical company name, removing suffixes like Inc, LLC, Ltd, and fixing capitalization. Input: " & A2) where A2='ACME corp., inc.'
Acme
Common mistakes to avoid
-
Leaving GPT formulas live
Every time Sheets recalculates, your formulas re-call the API. Open the file tomorrow and you pay again. Always convert completed columns to static values with Paste Special > Values Only.
-
Vague prompts that return essays
Asking 'Is this positive?' returns a paragraph. Asking 'Return Positive, Negative, or Neutral. One word only.' returns what you can filter and pivot on. Constrain the output space explicitly.
-
Ignoring rate limits on big sheets
Free-tier API keys cap at 3 requests per minute on some models. Running =GPT() on 2,000 rows will silently fail most of them. Throttle with Apps Script sleeps or upgrade your API tier before batch jobs.
-
Hardcoding your API key in a shared sheet
If you drop your key into Apps Script and share the sheet, collaborators can read it from the script editor. Store keys in PropertiesService.getUserProperties() or use an add-on that handles auth for you.
-
Trusting GPT for numeric lookups
Asking GPT to find a company's revenue or a person's email from a name is unreliable. It will confidently invent data. Use real data sources (Clearbit, Apollo, a database) and let GPT handle only text transformation.
Related queries
Frequently asked questions
Do I need an OpenAI API key to use ChatGPT in Google Sheets?
Yes for any real setup. Add-ons like GPT for Sheets ask you to paste your own OpenAI key, and custom Apps Script functions need it too. The key is separate from your ChatGPT Plus subscription and is billed per-token based on API usage.
How much does it cost to run ChatGPT on a full spreadsheet?
Roughly $0.15 to $2 per 1,000 rows depending on model and prompt length. gpt-4o-mini on short classification prompts is about 15 cents per 1,000 rows. gpt-4o on longer generation tasks can hit $5 or more. Always test on 20 rows first and multiply.
What is the best free add-on to connect ChatGPT to Google Sheets?
GPT for Sheets and Docs by Talarian is the most popular and has a free tier, though you still pay OpenAI for API calls. SheetAI and Numerous.ai are the main alternatives. All three give you a =GPT() function within a few minutes of install.
Can I use ChatGPT in Sheets without any add-on?
Yes. Open Extensions > Apps Script, write a function that calls https://api.openai.com/v1/chat/completions with UrlFetchApp, and you can call it as =GPT(A2) from any cell. This gives you full control over the model, temperature, and system prompt.
Why does my =GPT() formula return #ERROR or take forever?
Usually one of three things: your API key is missing or invalid, you hit a rate limit from too many simultaneous calls, or Google's custom function timeout (30 seconds) fired. Reduce concurrent calls, check your OpenAI dashboard for errors, and shorten prompts where possible.
Is my spreadsheet data sent to OpenAI when I use these functions?
Yes. Every cell value you pass into the prompt is sent to OpenAI's API. By default, API data is not used for training, but it does leave your Google Workspace. For sensitive data, use Azure OpenAI with a private endpoint or keep that data out of the prompt.