> ## Documentation Index
> Fetch the complete documentation index at: https://docs.altmagic.pro/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate Alt Text

> Generate descriptive alt text for images using AI with automatic fallback from Gemini to OpenAI



## OpenAPI

````yaml api-reference/openapi.json post /v1/generate-alt-text-api
openapi: 3.0.0
info:
  title: Alt Magic API
  description: Generate AI-powered alt text for images with automatic fallback
  version: 1.0.0
servers:
  - url: https://api.altmagic.pro
    description: Production API server
security: []
paths:
  /v1/generate-alt-text-api:
    post:
      tags:
        - Endpoints
      summary: Generate Alt Text
      description: >-
        Generate descriptive alt text for images using AI with automatic
        fallback from Gemini to OpenAI
      operationId: generateAltText
      requestBody:
        required: true
        content:
          application/json:
            examples:
              option-1-using-image-url:
                summary: Option 1 (using image URL)
                description: Generate alt text using a publicly accessible image URL
                value:
                  image_url: https://example.com/image.jpg
                  user_id: user@example.com
                  blog_title: Healthy Eating Guide
                  seo_keywords: healthy, food, nutrition, apples
                  language_code: en
              option-2-using-image-file:
                summary: Option 2 (using image file)
                description: >-
                  Generate alt text using a base64 encoded image file in data
                  URI format
                value:
                  image_file: >-
                    data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAABAAEDASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAv/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFQEBAQAAAAAAAAAAAAAAAAAAAAX/xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwCdABmX/9k=
                  user_id: user123
                  blog_title: Beautiful Sunset Over Mountains
                  seo_keywords: sunset, mountains, nature, landscape, photography
                  language_code: en
            schema:
              type: object
              required:
                - user_id
              anyOf:
                - required:
                    - image_url
                - required:
                    - image_file
              properties:
                image_url:
                  type: string
                  description: >-
                    Publicly accessible URL of the image to generate alt text
                    for. Either `image_url` or `image_file` must be provided.
                  format: uri
                image_file:
                  type: string
                  description: >-
                    Image file in data URI format with base64 encoded image
                    data. Format: `data:image/[type];base64,[base64-data]`.
                    Either `image_url` or `image_file` must be provided.
                  format: data-uri
                  example: >-
                    data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAABAAEDASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAv/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFQEBAQAAAAAAAAAAAAAAAAAAAAX/xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwCdABmX/9k=
                user_id:
                  type: string
                  description: >-
                    Unique identifier (email) for the user requesting the alt
                    text
                  format: email
                blog_title:
                  type: string
                  description: Blog or article title to provide additional context
                seo_keywords:
                  type: string
                  description: Comma-separated keywords for SEO optimization
                language_code:
                  type: string
                  description: >-
                    Language code (e.g., 'en', 'fr', 'es') for generated alt
                    text. If not provided, defaults to English ('en'). See
                    [Language Support](/api-reference/language-support) page for
                    complete list of supported languages.
      responses:
        '200':
          description: Successful alt text generation
          content:
            application/json:
              schema:
                type: object
                properties:
                  altText:
                    type: string
                    description: The generated alt text
                  CreditsAvailable:
                    type: integer
                    description: Remaining credits for the user after this request
                  plan_type:
                    type: string
                    description: The user's subscription plan
        '400':
          description: Bad request - invalid parameters
        '401':
          description: Unauthorized - invalid or missing API key
        '403':
          description: Forbidden - no credits remaining
        '404':
          description: User not found
        '429':
          description: Too many requests - rate limit exceeded
        '500':
          description: Internal server error
      security:
        - apiKeyAuth: []
components:
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.