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 alt text in several 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. Defaults to en.
regenerateBooleanNoSkip the cache and regenerate the alt text in all supported languages. Also removes every manual override for the image, so the response contains only fresh AI-generated text. 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).

Supported Languages

Alt text can be generated in the following languages. Requesting any other language returns a 400 response.

CodeLanguage
enEnglish
frFrench
deGerman
itItalian
esSpanish

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. 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 regenerate the image’s alt text with regenerate=true, which removes all overrides for the image.

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, 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 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": []
# }