Bulk write alt text with ChatGPT in Excel and Google Sheets

Use GPT for SheetsGPT_VISION function in Google Sheets to automatically generate alt text for e-commerce applications. Alt text will improve your website’s accessibility, which benefits users and improves your SEO ranking.

This guide will walk you through how to quickly and easily generate alt text for an e-commerce application using GPT for Sheets and GPT for Excel.

By the end of this guide, you will know:

  • What alt text is, and what purposes it serves.
  • How to automatically generate effective alt text for a diverse range of product images
  • How to use the GPT_VISION function
  • How accessibility and SEO benefit users and search engine rankings

What is alt text and what purposes does it serve?

Alt text is a brief text description of an image included in the code of a webpage. Adding alt text has several important purposes:

Website Accessibility: Alt text helps visually impaired users and other people with disabilities understand the content on your webpage. Screen reader users can read alt text to aid comprehension. A better user experience means more users will interact positively with your site and help build brand loyalty. Creating an inclusive e-commerce environment helps comply with regulatory guidelines like WCAG.

SEO: Search engines like Google use alt text to understand an image’s content. High-quality alt text can make images more searchable and boost your website’s visibility, improving your search ranking and attracting more site traffic.

Context: Alt text can provide additional information and context about the image that may not be immediately clear. Context ensures users can understand the visual content on your website.

Fail-Safe: Alt text will be displayed when images fail to load on your webpage. Alt text provides users with valuable content descriptions even when missing images, which in turn improves SEO.

By using GPT_VISION to automate your alt text generation, you can save time and be confident that your alt text is high-quality.

Best Practices

Alt text should contain the following qualities to be effective:

Brief: 1-2 sentences.

Non-Self Referential: Avoid writing "this is an image of" or "this is a picture of".

Focused: Describe key elements of the image.

Additive: Provide new text that isn’t already present elsewhere.

Defined: Always include a period.

Harvard’s Digital Accessibility Guide provides more information on best practices for writing descriptive alt text.

Generating alt text for product images with the GPT_VISION function

To begin this tutorial, you need to complete the following prerequisites:

Getting Started

GPT_VISION can effectively generate alt text of images in just a few steps.

Open GPT for Sheets using the Extensions menu at the top of your document.

Enter the following formula and prompt in a new column where you want your alt text to appear.

=GPT_VISION("Generate alt text <15 words, following best practices from the Harvard University accessibility guide to improve website accessibility and SEO",C4)

Allow the function to run and check the result.

If you’re satisfied with the result, hover over the bottom right of the cell containing your formula and drag the Fill Handle to the bottom of the cell range you want to process.

Always remember to replace your formulas to avoid recalculation when you have finished generating alt text.

If you’re using GPT for Excel, you can use the Prompt images(Vision)  bulk tool instead of manually dragging to apply GPT_VISION to cells.

Start by entering your prompt and specifying the column containing your image URLs and the column in which you would like to place your alt text.

Then, run the tool on the first three rows (starting at row 4 in the tutorial file).

If you’re satisfied with the result, run the tool on the rest of your rows.

GPT for Excel also includes advanced parameters and modifiers, which you can read about here.

Improving your results (optional)

While this prompt provides effective and concise alt text for a diverse range of product images, a few considerations may improve your results.

Adding context to the prompt

If you are writing alt text for a specific product category or type, you can insert additional information into the prompt.

You can insert details about the product itself. A sample prompt would look like this:

=GPT_VISION("Generate alt text for merino wool sweaters, <15 words, following best practices from the Harvard University accessibility guide to improve website accessibility and SEO",C4)

Another technique you can try is specifying certain visual information to appear in the output, such as shape and color:

=GPT_VISION("Generate alt text, <15 words, describe shape, color, and, texture, following best practices from the Harvard University accessibility guide to improve website accessibility and SEO",C4)

Try modifying these prompts to your needs!

Image quality

E-commerce product photos are most effective when they feature a single well-lit identifiable subject on an empty background shot from a level angle; if your photos have multiple items in focus, poor lighting, or are using styled in-situ photos, you may not get your desired results.

Estimating token cost

GPT_VISION utilizes OpenAI’s Vision feature. Your token cost is determined by how GPT_VISION processes your images, the token costs of your prompt, and the output you receive.

Higher-resolution images use more tokens, which can be costly if you’re processing hundreds or thousands of photos. However, GPT_VISION offers a high_res parameter that modifies how the AI processes your image. By default, this function is set to auto and will automatically process your image according to its size. If you use high-resolution images, you can try changing the parameter to false to reduce token costs.

Your new formula would look like this:

=GPT_VISION("Generate alt text <15 words, following best practices from the Harvard University accessibility guide to improve website accessibility and SEO",C4,false)

Setting high_res to false will use OpenAI’s "low res" mode for the Vision detail parameter, incurring a flat cost of 85 tokens per image. When high_res is set to true, it will incur the same 85-token flat cost plus an additional cost for each tile Vision uses to process the image. For images in a 1:1 aspect ratio that are larger than 512 pixels (such as product photos), Vision will process them as four tiles. This means a 1024x1024 pixel image will cost the same to process as a 4096x4096 pixel image.

You can learn more about how Vision processes images, including details on tiles, by reading OpenAI’s API and the OpenAI Developer Forum.

Refer to the following tables to estimate your total token costs. Please note that token costs are approximate, and actual rates will vary depending on your images, prompt, and output.

Estimated token cost for one image

Image Resolution
Image Tokens
Prompt Tokens
Output Tokens
Total Tokens
Cost $
‘Low’
85
~21
~13.4
~119.4
~$0.00239
512 × 512px
255
~21
~13.4
~289.4
~$0.00579
1024 × 1024px
765
~21
~13.4
~799.4
~$0.01599
ℹ️
Prompt and output costs are based on the tutorial above.

Estimated token cost by number of generations

Image Resolution
Generations
Total Token Cost
Cost $
‘Low’
1
~119
~$0.0024
40
~4,760
~$0.10
100
~11,900
~$0.24
1,000
~119,000
~$2.38
512px × 512px
1
~289
~$0.01
40
~11,560
~$0.23
100
~28,900
~$0.58
1,000
~289,000
~$5.78
1024px × 1024px
1
~799
~$0.016
40
~31,960
~$0.64
100
~79,900
~$1.60
1,000
~799,000
~$15.98
ℹ️
A generation includes image processing, prompt, and output.

Additionally, GPT_VISION always uses gpt4o. If you have high enough rate limits, using your API key can reduce costs. Learn more about our pricing.

Visit our documentation for a complete list of parameters and features GPT_VISION offers.

Conclusion

You should now have a strong understanding of how  GPT_VISION in GPT for Sheets can automate alt text generation for product images. This automation saves you time, improves your users' experience, and benefits your search ranking through SEO in e-commerce scenarios.

We would love to hear if you enjoyed this guide or have suggestions for the next one. If you want to try this exercise yourself, use the Generating Alt Text For E-Commerce Tutorial. Remember to check out the rest of our guides and documentation for GPT for Sheets and the rest of our GPTforwork products.