I built a service that auto-generates unique h1, alt text, and titles for images using OpenAI. This improved SEO, accessibility, reduced content cannibalization, and saved time for authors.I built a service that auto-generates unique h1, alt text, and titles for images using OpenAI. This improved SEO, accessibility, reduced content cannibalization, and saved time for authors.

Automation of ALT Text Generation for Images Using the OpenAI API

2025/09/10 16:03
5분 읽기
이 콘텐츠에 대한 의견이나 우려 사항이 있으시면 crypto.news@mexc.com으로 연락주시기 바랍니다

Hello, I’m a developer who has been building websites for some time. Not long ago, I took part in the development of a website that is still in its early stages. This is my test project for checking my own features (my first commercial project where I also worked on the server-side of the website; before that, I had experience creating a small REST API using Express.js, but here the server was built with Nest.js).

I won’t go into too many details now – instead, in this article I’ll write about the benefits I personally gained from this experience. (It might be within the next few days or weeks, I’ll either highlight a quote in this blog or leave a link in the comments here.)

\

Introduction to the Core of the Problem

One of the main and key problems is the lack of a unique h1 on image pages (many website SEO checking services report non-unique errors as a critical or medium-level issue), which is indexed by GoogleBot and participates in search results and Google Images.

The problem was the absence of alt in images, which are needed to improve SEO and adjust settings in Google Images, including to improve the accessibility of your website (see the European Directive on the accessibility of digital products and services, effective June 28, 2025):

\

  • problems when including an image;
  • for people with visual impairments, screen readers read the alt;
  • content cannibalization, for example, in the title and alternative images, leads to the use of titles to which the image belongs; in the web project, there were a large number of such titles.

\

An Example of This Problem Was Solved

The old version of the title and alternative text that was used looked like this, for example with this image – FlatOut 2 Screenshot 48. Below is the current version, which was generated with AI.

Example of a New Generated h1 for an Image Page

\ Example of a Generated alt for an Image

\ PS: The image description and caption were also generated with AI, but later we abandoned this idea since we cannot fully create the description – it turns out too long. (You can see an example here, and you can also compare this description – these were our first attempts based on the game description with the addition of the page. We eventually concluded that it was useless, but we decided to leave it in these test cases.)

\

Problem Solution

At the moment, I’ve written a test version – a small service that uses the OpenAI API and a function that provides prompts for AI templates of input data and configuration settings. (By the way, the new GPT-5 version no longer has the temperature parameter; previously, this parameter influenced creativity – see more details).

The next step in the development was a function in the image service, which is responsible for retrieving images that don’t yet have an alt or title. This function worked with a limit on the number of images to avoid overload. The p-limit library was used to manage parallel requests to the OpenAI API and speed up data generation.

So, we now have a ready function that can generate textual descriptions for images.

Currently, I use a cron function to trigger this process at intervals. In other words, I don’t generate alt text immediately at the time of image upload and don’t execute this operation in a separate queue (like Bull, BullMQ, and others).

\ At the moment, I am using the version gpt-4_1-mini-2025-04-14

OpenAI API Usage Metrics

Some Numbers:

  • 46.82s execution time for 5 requests to the OpenAI API with p-limit 1;
  • 19.71s - 23.12sExecution time for 5 requests using a p-limit of 3;

\

\ The price of this version is quite low: when generating alt text and titles for around 2,200 images, the cost was $5.5. I also tested more expensive versions but did not notice any significant improvement in the quality of generation or the accuracy of the image descriptions.

\

What We Achieved in the End

  • Unique page title;
  • Fully filled-in alt text;
  • Reduced cannibalization in the project;
  • Reduced workload for content authors (a concrete example: a website created in 6 languages, where authors cannot always afford to add alt/title to images in all languages - and in most cases, they don’t even want to do it in one language);
  • More attractive and enriched snippets in search results;
  • OpenGraph metadata, which can attract users from social networks.

In conclusion, I can say that the idea came naturally, although it is far from new.

Today, you can already find many ready-made solutions in search. If anyone needs help with such a custom implementation, here is my GitHub.

\


\

Sources:

  • European Directive on the accessibility of digital products and services;
  • Example website;
  • p-limit – a library for controlling concurrency of Promises;
  • Cheat sheet on the temperature[ and ]()top_p[ parameters in the ChatGPT API]();
  • GitHub (for contact).

\ \ \ \ \

면책 조항: 본 사이트에 재게시된 글들은 공개 플랫폼에서 가져온 것으로 정보 제공 목적으로만 제공됩니다. 이는 반드시 MEXC의 견해를 반영하는 것은 아닙니다. 모든 권리는 원저자에게 있습니다. 제3자의 권리를 침해하는 콘텐츠가 있다고 판단될 경우, crypto.news@mexc.com으로 연락하여 삭제 요청을 해주시기 바랍니다. MEXC는 콘텐츠의 정확성, 완전성 또는 시의적절성에 대해 어떠한 보증도 하지 않으며, 제공된 정보에 기반하여 취해진 어떠한 조치에 대해서도 책임을 지지 않습니다. 본 콘텐츠는 금융, 법률 또는 기타 전문적인 조언을 구성하지 않으며, MEXC의 추천이나 보증으로 간주되어서는 안 됩니다.

USD1 Genesis: 0 Fees + 12% APR

USD1 Genesis: 0 Fees + 12% APRUSD1 Genesis: 0 Fees + 12% APR

New users: stake for up to 600% APR. Limited time!