Imgix APIsGenerations APIAlt Text Generation

Alt Text Generation

The Generations API can produce AI-generated alt text for an Imgix image, written for screen readers and other assistive technology. You can request up to 10 of the 52 supported languages in a single call.

If the generated text isn’t quite right, you can also edit it by setting a manual override per language. Overrides are stored alongside the AI-generated text and take precedence whenever alt text for that image is requested.

Unlike Video Generation, alt text generation is synchronous: the generated text is returned directly in the response, with no job to poll.

Authentication

All calls to the Generations API require an API key with any permission (billing, asset manager read, etc). To create a key, navigate to the API Keys view in your Dashboard. The API key’s account must own the Source that serves the image.

Alt Text Operations

EndpointMethodDescription
/v1/generations/alt-textGETGenerate alt text for an image in one or more languages.
/v1/generations/alt-textPOSTSet or remove manual alt-text overrides for an image, per language.

Generating Alt Text

To generate alt text, make a GET request to /v1/generations/alt-text, identifying the image with either url or url64.

Request Parameters

ParameterTypeRequiredDescription
urlStringOne of url/url64A plain Imgix render URL with no query parameters (e.g. https://assets.imgix.net/photo.jpg).
url64StringOne of url/url64A base64url-encoded Imgix render URL. Use this when the URL carries query parameters, such as AI generation parameters.
languageStringNoA BCP-47 language code. Repeat the parameter or pass a comma-separated list for multiple languages, up to 10 per request. Matched case-insensitively. Defaults to en.
regenerateBooleanNoSkip the cache and regenerate the requested languages, replacing whatever was stored for them and removing their manual overrides so the response contains fresh AI-generated text. Languages you didn’t request keep both their stored text and their overrides. Defaults to false.

Note: Provide exactly one of url or url64. Use url for a clean image URL and url64 whenever the URL contains query parameters (for example, an image produced with text2image).

How generation and caching work

Generated alt text is stored per image, so repeat requests are served from storage rather than regenerating.

Each request generates only the languages that aren’t already available for that image. If you ask for pl,nl,ru,de and later ask for pl,nl,ru,de,th, only Thai is generated — the other four are returned exactly as before, character for character. Languages you have overridden are also already available, so they are never regenerated either.

Different renders of the same image share stored alt text: photo.jpg?w=200 and photo.jpg?fit=crop&h=400 are the same picture, so they reuse the same text. Images generated with text2image are treated as distinct, since a different prompt is a different picture.

To replace text you already have, use regenerate=true.

Supported Languages

Alt text can be generated in the 52 languages below. Codes are matched case-insensitively, so PT and zh-hant are accepted. Requesting any other language returns a 400 response.

Chinese is addressed by script rather than as a bare zh, since Simplified and Traditional are different text.

CodeLanguage
arArabic
bnBengali
bgBulgarian
caCatalan
hrCroatian
csCzech
daDanish
nlDutch
enEnglish
etEstonian
filFilipino
fiFinnish
frFrench
deGerman
elGreek
guGujarati
heHebrew
hiHindi
huHungarian
isIcelandic
idIndonesian
itItalian
jaJapanese
knKannada
koKorean
lvLatvian
ltLithuanian
msMalay
mlMalayalam
mrMarathi
nbNorwegian Bokmål
faPersian
plPolish
ptPortuguese
paPunjabi
roRomanian
ruRussian
srSerbian
zh-HansSimplified Chinese
skSlovak
slSlovenian
esSpanish
swSwahili
svSwedish
taTamil
teTelugu
thThai
zh-HantTraditional Chinese
trTurkish
ukUkrainian
urUrdu
viVietnamese

Requesting more than 10 languages

A single request accepts at most 10 languages; more returns a 400. Split the rest across further requests. Each request is metered separately, so asking for several languages at once costs less than asking for them one at a time.

Response

The response contains an alt_text object keyed by the requested language codes, and a failed_languages array listing any requested languages that could not be generated.

AttributeTypeDescription
alt_textObjectMap of language code to the alt text string, for each requested language. Languages with a manual override return the override text instead of the AI-generated text.
failed_languagesArrayLanguage codes that were requested but could not be generated. Empty on full success.
overridden_languagesArrayRequested language codes whose alt_text value came from a manual override rather than AI generation.
GET api/v1/generations/alt-text?url=https://assets.imgix.net/photo.jpg&language=en,fr

Generating alt text for a URL with parameters

When the image URL contains query parameters — for example an AI image created with text2image — base64url-encode the full URL and pass it as url64:

# Plain URL (contains query parameters):
# https://assets.imgix.net/ai?text2image=true&prompt=a serene mountain lake at sunset
 
GET api/v1/generations/alt-text?url64=aHR0cHM6Ly9hc3NldHMuaW1naXgubmV0L2FpP3RleHQyaW1hZ2U9dHJ1ZSZwcm9tcHQ9YSBzZXJlbmUgbW91bnRhaW4gbGFrZSBhdCBzdW5zZXQ&language=en

Editing Alt Text

If an AI-generated description needs adjusting — for example to name a product or match your brand’s voice — you can set a manual override per language by making a POST request to /v1/generations/alt-text. Overrides take precedence over AI-generated text: once set, the GET endpoint returns your text for that language and lists the language in overridden_languages.

Overrides can only be set for an image that already has generated alt text. Generate it first with a GET request; a POST for an image with no generated alt text returns a 409.

Request Body

The request body is a JSON object identifying the image with exactly one of url or url64 (same semantics as the GET endpoint), plus an alt_text object with the overrides to apply.

FieldTypeRequiredDescription
urlStringOne of url/url64A plain Imgix render URL with no query parameters.
url64StringOne of url/url64A base64url-encoded Imgix render URL, for URLs that carry query parameters.
alt_textObjectYesMap of language code to the override text. A null value removes that language’s override, reverting it to the AI-generated text. Must contain at least one language.

You can set and remove overrides for any subset of the supported languages in a single request; the 10-language limit applies to generation, not to overrides. Language codes are matched case-insensitively. Override text must be non-empty (use null to remove, not an empty string) and at most 2,000 characters per language.

Response

AttributeTypeDescription
alt_textObjectThe overrides that were set, keyed by language code.
removed_languagesArrayLanguage codes whose overrides were removed.
POST api/v1/generations/alt-text
{
  "url": "https://assets.imgix.net/photo.jpg",
  "alt_text": {
    "en": "Maya the havanese puppy sitting on a wooden floor, looking up at the camera",
    "fr": null
  }
}

Overrides and credits

Setting or removing overrides never calls the AI model, so POST requests do not consume AI credits. Overrides persist until you remove them with a null value, or until you regenerate that language with regenerate=true. Regenerating one language does not affect overrides in any other language.

An overridden language counts as already available, so it is not regenerated while the override is in place. Removing an override reveals the AI-generated text underneath if that language was generated before; if it was not, the next request for it generates it.

Status Codes

Status CodeDescription
200OK - Alt text generated (or served from cache) successfully, or overrides applied successfully.
400Bad Request - Missing or invalid url/url64, an unsupported language, more than 10 languages in one request, or invalid override text (empty, or over 2,000 characters).
402Payment Required - The account’s AI credits are depleted (plan_credits_depleted_payment_required). GET only.
403Forbidden - Alt text generation is not enabled for the Source, or the API key does not own the Source.
409Conflict - POST only. No generated alt text exists for the image yet; generate it first with a GET request.
500Internal Server Error - The image could not be fetched, generation failed for every requested language, or the overrides could not be stored.

Credit usage

Alt text generation is metered against your account’s AI credits. A request that generates alt text is metered once, whatever the number of languages — requesting ten languages costs the same as requesting one. Requests served entirely from stored text or overrides are not metered at all, and neither are POST requests.

Because metering is per request, generating languages together is cheaper than generating them one at a time. A 402 response indicates the account’s credits are depleted; generation resumes once the balance is replenished.

Examples

Generating alt text

curl -X GET "https://api.imgix.com/api/v1/generations/alt-text?url=https://assets.imgix.net/photo.jpg&language=en,es" \
  -H "Authorization: Bearer YOUR_API_KEY"
# Response:
# {
#   "alt_text": {
#     "en": "a havanese puppy sitting on a wooden floor, looking up at the camera",
#     "es": "un cachorro habanero sentado en un suelo de madera, mirando a la cámara"
#   },
#   "failed_languages": [],
#   "overridden_languages": []
# }

Editing alt text

curl -X POST "https://api.imgix.com/api/v1/generations/alt-text" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://assets.imgix.net/photo.jpg",
    "alt_text": {
      "en": "Maya the havanese puppy sitting on a wooden floor, looking up at the camera"
    }
  }'
# Response:
# {
#   "alt_text": {
#     "en": "Maya the havanese puppy sitting on a wooden floor, looking up at the camera"
#   },
#   "removed_languages": []
# }