/v1/alt-textπ API KeyGenerate WCAG-compliant alt text for an image.
Request
POST /v1/alt-text
Content-Type: application/json
X-API-Key: alt_YOUR_API_KEY
{
"image_url": "https://example.com/photo.jpg",
"language": "en",
"context": "Product photo for ecommerce",
"max_length": 125,
"style": "descriptive"
}
Parameters
| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| image_url | string | Yes | β | Public HTTPS URL of the image |
| language | string | No | "en" | ISO 639-1 language code |
| context | string | No | β | Additional context about the image |
| max_length | integer | No | 125 | Max characters for alt text |
| style | string | No | "descriptive" | "descriptive" or "concise" |
Response
Success (200)
{
"alt_text": "A modern ergonomic office chair with black mesh back and adjustable armrests against a white background.",
"credits_remaining": 37,
"wcag_compliant": true,
"character_count": 118,
"processing_time_ms": 1520
}
| Field | Type | Description |
|-------|------|-------------|
| alt_text | string | The generated alt text |
| credits_remaining | integer | Credits left this billing period |
| wcag_compliant | boolean | Whether the alt text meets WCAG 2.1 AA |
| character_count | integer | Length of the generated alt text |
| processing_time_ms | integer | Time taken to generate |
Error (400)
{
"error": {
"code": "invalid_image_url",
"message": "The provided URL does not point to a valid image.",
"docs": "https://altextapi.com/docs/api-reference/errors"
}
}
Examples
Basic Usage
curl -X POST https://api.altextapi.com/v1/alt-text \
-H "Content-Type: application/json" \
-H "X-API-Key: alt_YOUR_API_KEY" \
-d '{"image_url": "https://example.com/sunset.jpg"}'
With Context and Language
curl -X POST https://api.altextapi.com/v1/alt-text \
-H "Content-Type: application/json" \
-H "X-API-Key: alt_YOUR_API_KEY" \
-d '{
"image_url": "https://example.com/produkt.jpg",
"language": "de",
"context": "Produktfoto fΓΌr Online-Shop",
"style": "concise"
}'
Processing time
Typical processing time is 1-2 seconds. Large images (over 5MB) may take up to 4 seconds. Timeout is 15 seconds.