API Documentation

Complete guide to integrating AltText API for generating accessible, WCAG 2.1 AA compliant alt text using AI.

Overview

AltText API provides a simple REST API for generating high-quality alt text for images using advanced AI vision models.

Key Features

  • 2-3 second response times
  • WCAG 2.1 AA compliant output
  • 32+ languages supported
  • Batch processing (up to 50 images)
  • 99.9% uptime guarantee
  • Privacy-first (images not stored)

Base URL

https://alttextapi.com

Pricing

  • $0.03 per image (3 cents)
  • No monthly fees or subscriptions
  • Pay only for successful generations
  • Minimum purchase: $5 (166 images)

WCAG 2.1 Compliance

AltText API generates alt text that helps you meet WCAG 2.1 Level AA Success Criterion 1.1.1 (Non-text Content), which requires meaningful alternative text for images.

Important: While our AI generates high-quality, accessibility-focused alt text, you are responsible for ensuring compliance. We recommend reviewing AI-generated content before publishing, especially for:
  • Legal documents and contracts
  • Medical or healthcare content
  • Financial information
  • Critical accessibility applications
  • Content requiring precise technical descriptions

What We Provide

  • Contextual Descriptions: Our AI analyzes images to provide meaningful, descriptive alt text
  • Concise Format: Alt text is kept under 125 characters when possible for optimal screen reader experience
  • Multi-Language Support: Generate alt text in 32+ languages for international accessibility
  • Consistent Quality: Advanced vision models (Qwen 2.5 VL, Gemini 2.5) ensure reliable output

Your Responsibility

  • Review Generated Content: AI is a tool to assist, not replace, human judgment
  • Context Matters: Ensure alt text fits the surrounding content and purpose
  • Decorative Images: Use empty alt="" for purely decorative images (API doesn't make this decision)
  • Complex Images: Charts, diagrams, and infographics may need longer descriptions beyond alt text
  • Final Compliance: You are responsible for ensuring your implementation meets accessibility standards
Best Practice: Use AltText API to generate initial alt text, then have content editors or accessibility specialists review and refine as needed for your specific use case.

Quick Start

1. Create Account

Sign up at alttextapi.com to get your API key.

2. Get API Key

After signing up, find your API key in the dashboard.

3. Make Your First Request

curl -X POST https://alttextapi.com/api/generate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "image_url": "https://example.com/image.jpg",
    "language": "en"
  }'

4. Get Response

{
  "alt_text": "A golden retriever playing fetch in a park",
  "language": "en",
  "cost": "$0.03",
  "balance": "$9.97",
  "images_remaining": 332
}

Authentication

All API requests must include your API key in the Authorization header using the Bearer scheme:

Authorization: Bearer YOUR_API_KEY

API Key Format: Keys start with ak_ followed by 48 hexadecimal characters (e.g., ak_a1b2c3d4...)

Keep your API key secret! Never commit it to version control or expose it in client-side code. Anyone with your API key can use your credits.

Getting Your API Key

  1. Sign up at alttextapi.com
  2. Log in to your dashboard
  3. Copy your API key
  4. Store it securely (use environment variables)

API Endpoints

POST /api/generate

Generate alt text for a single image.

Request Body

Parameter Type Required Description
image_url string Required* Public URL of the image
image_base64 string Required* Base64-encoded image data (alternative to image_url)
language string Optional Language code (e.g., "en", "es", "fr"). Default: "en"

* Either image_url or image_base64 is required

Response

{
  "alt_text": "A golden retriever playing fetch in a park",
  "language": "en",
  "cost": "$0.03",
  "balance": "$9.97",
  "images_remaining": 332
}
POST /api/batch

Generate alt text for multiple images (up to 50 per request).

Request Body

Parameter Type Required Description
images array Required Array of image objects (max 50)
language string Optional Language code for all images. Default: "en"

Example Request

{
  "images": [
    {"image_url": "https://example.com/image1.jpg"},
    {"image_url": "https://example.com/image2.jpg"},
    {"image_base64": "iVBORw0KGgoAAAA..."}
  ],
  "language": "en"
}

Response

{
  "results": [
    {
      "success": true,
      "alt_text": "A golden retriever playing fetch"
    },
    {
      "success": true,
      "alt_text": "A sunset over the ocean"
    },
    {
      "success": false,
      "error": "Invalid image URL"
    }
  ],
  "total": 3,
  "successful": 2,
  "failed": 1,
  "cost": "$0.06",
  "balance": "$9.91",
  "images_remaining": 330
}
GET /api/me

Get your account information and current balance.

Response

{
  "email": "user@example.com",
  "balance": "$9.97",
  "total_spent": "$0.03",
  "images_remaining": 332
}
POST /api/signup

Create a new account.

Request Body

Parameter Type Required Description
email string Required Your email address
password string Required Password (min 8 characters)
name string Optional Your name

Response

{
  "message": "Account created successfully",
  "api_key": "sk_live_abc123...",
  "email": "user@example.com"
}
POST /api/login

Log in to your account.

Request Body

Parameter Type Required Description
email string Required Your email address
password string Required Your password

Response

{
  "email": "user@example.com",
  "api_keys": [
    {
      "key": "sk_live_abc123...",
      "name": "Default",
      "created_at": "2025-09-30T12:00:00Z"
    }
  ]
}

Code Examples

cURL

curl -X POST https://alttextapi.com/api/generate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "image_url": "https://example.com/image.jpg",
    "language": "en"
  }'

JavaScript (Node.js)

const response = await fetch('https://alttextapi.com/api/generate', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.ALTTEXT_API_KEY}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    image_url: 'https://example.com/image.jpg',
    language: 'en'
  })
});

const data = await response.json();
console.log(data.alt_text);

Python

import requests
import os

response = requests.post(
    'https://alttextapi.com/api/generate',
    headers={
        'Authorization': f'Bearer {os.getenv("ALTTEXT_API_KEY")}',
        'Content-Type': 'application/json'
    },
    json={
        'image_url': 'https://example.com/image.jpg',
        'language': 'en'
    }
)

data = response.json()
print(data['alt_text'])

PHP

$ch = curl_init('https://alttextapi.com/api/generate');

curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . getenv('ALTTEXT_API_KEY'),
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'image_url' => 'https://example.com/image.jpg',
    'language' => 'en'
]));

$response = curl_exec($ch);
$data = json_decode($response, true);

echo $data['alt_text'];

Ruby

require 'net/http'
require 'json'

uri = URI('https://alttextapi.com/api/generate')
request = Net::HTTP::Post.new(uri)
request['Authorization'] = "Bearer #{ENV['ALTTEXT_API_KEY']}"
request['Content-Type'] = 'application/json'
request.body = {
  image_url: 'https://example.com/image.jpg',
  language: 'en'
}.to_json

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
  http.request(request)
end

data = JSON.parse(response.body)
puts data['alt_text']

Error Handling

HTTP Status Codes

Code Status Description
200 OK Request successful
400 Bad Request Invalid request parameters
401 Unauthorized Invalid or missing API key
402 Payment Required Insufficient credits
429 Too Many Requests Rate limit exceeded
500 Internal Server Error Server error (we're notified automatically)

Error Response Format

{
  "error": "Insufficient credits. Please add more credits to continue."
}

Common Errors

Insufficient Credits

{
  "error": "Insufficient credits"
}

Solution: Add credits at /dashboard

Invalid API Key

{
  "error": "Invalid API key"
}

Solution: Check your API key in the dashboard

Invalid Image URL

{
  "error": "Invalid or inaccessible image URL"
}

Solution: Ensure the image URL is publicly accessible

Rate Limits

AltText API has generous rate limits to support production applications:

  • No hard rate limits on paid accounts
  • Automatic fallback between AI providers ensures reliability
  • Cloudflare Workers can handle millions of requests
  • 99.9% uptime guarantee
Fair Use Policy: If you need to process extremely large volumes (1M+ images/month), please contact us for enterprise pricing.

Best Practices

  • Use batch processing for multiple images
  • Implement retry logic with exponential backoff
  • Cache generated alt text to avoid duplicate requests
  • Monitor your balance to avoid service interruption

Integrations

WordPress

Official WordPress plugin available for automatic alt text generation.

Features

  • Auto-generate alt text on image upload
  • Bulk process existing images
  • WooCommerce support
  • Multi-language support

Installation

  1. Download the plugin from our GitHub
  2. Upload to WordPress → Plugins → Add New
  3. Activate and enter your API key
  4. Enable auto-generate in Settings → AltText API

Shopify (Coming Soon)

Shopify app integration is in development. Join our waitlist in the dashboard.

Custom Integration

Use our REST API to integrate with any platform:

  • Content Management Systems (Drupal, Joomla, etc.)
  • E-commerce platforms (Magento, BigCommerce, etc.)
  • Custom applications
  • Automation tools (Zapier, Make, etc.)

Support

Resources

Common Questions

Do you store my images?

No. Images are processed in-memory only and immediately discarded. We never store your images.

Is the alt text WCAG compliant?

Yes. All generated alt text meets WCAG 2.1 Level AA standards. However, we recommend human review for critical applications.

What languages are supported?

32+ languages including English, Spanish, French, German, Chinese, Japanese, and more.

Can I get a refund?

Credits are non-refundable once purchased, but they never expire.

Need Help?

For technical support or questions, check our GitHub repository or contact us through the dashboard.

Ready to get started? Get your API key →