Generate Image Alt Text With an API

You can draft alt text for images by sending each picture to an AI model that understands images, then reviewing what it returns before saving it to your site. The model gives you a starting description in seconds. A person confirms it is accurate and fits the context. Treat it as a time saver for the first draft, not as a replacement for judgment.
Alt text matters because screen readers speak it aloud for people who cannot see the image, and it appears when an image fails to load. It also gives search engines context about the page.
What good alt text looks like
Good alt text describes what the image contributes to the page, in a short sentence or two. A photo of a laptop on a desk in an article about remote work might be described as “Laptop open on a wooden desk beside a coffee cup.” A chart should say what it shows: “Bar chart showing monthly signups rising from January to June.”
Keep these points in mind.
- Be specific and concise, usually under about 125 characters, though there is no hard limit.
- Skip phrases like “image of” or “picture of,” because screen readers already announce an image.
- Include any text that appears in the image if it matters.
- Describe the meaning, not every pixel.
- Leave alt text empty for purely decorative images, so screen readers skip them.
The right description depends on context. The same photo might need different alt text in a news story than in a product page.
Where automation helps
Many sites have hundreds of images with no alt text. Writing each by hand is slow and so it never happens. An automated first pass can fill the gap and leave you with a short review job.
The workflow is straightforward. Collect the image files or their addresses. For each one, send it to a vision-capable model with a prompt asking for a short description. Save the response next to the image in a sheet. A person edits the sheet. Finally, a second step writes the approved text back to the site.
Keep the sheet as the gate between generation and publishing. Nothing goes to the live site until a person marks the row approved.
Write a useful prompt
The quality of the result depends on the instructions. Tell the model who it is writing for and what the page is about. A prompt might say that the description is alt text for a web page about a given topic, should be under a set length, should not begin with “image of,” and should note visible text.
Pass context when you have it, such as the post title or the caption. Context lets the model describe what matters. A photo of a chart in an article on pricing needs different emphasis than the same chart in an article on design.
Ask the model to say “decorative” when an image has no informational value, such as a plain divider or background texture. Then review those flagged rows.
Make the API call
Most AI providers offer an API that accepts an image along with text. You usually send the image either as an encoded string in the request or as an address the service can reach. Check the documentation of the provider you use for the exact format, size limits and pricing, since all change often.
Resize large images before sending. A smaller version is usually enough for description and costs less to process.
Add a delay between calls and watch for rate limits. Process in small batches, and log failures so you can retry them without starting over.
Review before publishing
Read every description. Models can misidentify objects, guess at details, or describe a person’s appearance or emotions with unwarranted certainty. For photos of people, avoid assumptions about identity, age or background, and describe only what is evident and relevant.
Check also for repeated openings and filler. Edit toward natural, plain language. Where the image carries meaning that the model cannot know, such as a product name, a place or an event, add it yourself.
Spot-check a larger share at the start. Once you trust the prompt, you can review a smaller sample, but never drop the check completely for important pages.
Write the text back
For WordPress, the media library stores alt text as a field on each item, which can be updated through its API. Other platforms have similar fields. Update by the image’s ID, and keep a log of what changed and when so you can reverse a mistake.
If images in posts are embedded with their own alt attributes, you may need to update the post content instead. Test on one post before changing many.
Keep it going
Add a step to your publishing workflow so new images get a draft description as part of upload. The review happens with the rest of the post’s checks.
Remember that automated text is a start. Accessibility is about real readers, so, if possible, ask someone who uses a screen reader to test a few pages.
It also helps to keep a short style guide for alt text: how to describe charts, how to name products, whether to mention colors, and what to do with logos. A guide of ten lines makes both the prompt and the review more consistent, and it gives future contributors a standard to follow.
Your next step
Pick ten images from your site that lack alt text. Run them through a vision-capable model with a short prompt, and put the results in a sheet. Edit each description by hand and note how often you had to change it.
If most needed only small fixes, build the full workflow for the rest. If many were wrong, improve the prompt with context before scaling.