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

# Generate Alt Text

> Generate alt text for a single image

## Overview

Generate accurate, descriptive alt text for a single image using advanced AI models.

<Endpoint method="post" url="/generate" />

## Request Body

<ParamField body="image_url" type="string" required>
  The URL of the image to generate alt text for
</ParamField>

<ParamField body="api_key" type="string" required>
  Your GistMag API key
</ParamField>

<ParamField body="mode" type="string" default="short">
  The length of alt text to generate. Options: `short`, `long`, `seo`
</ParamField>

## Example Request

```bash theme={null}
curl -X POST https://api.gistmag.co.uk/generate \
  -H "Content-Type: application/json" \
  -d '{
    "image_url": "https://example.com/sunset.jpg",
    "api_key": "your_api_key_here",
    "mode": "short"
  }'
```

## Response

<ResponseField name="alt_text" type="string">
  The generated alt text description
</ResponseField>

<ResponseField name="confidence" type="number">
  Confidence score (0-1) of the generated alt text
</ResponseField>

<ResponseField name="credits_used" type="number">
  Number of credits consumed for this request
</ResponseField>

### Example Response

```json theme={null}
{
  "alt_text": "A beautiful sunset over the ocean with orange and pink hues",
  "confidence": 0.95,
  "credits_used": 1
}
```

## Error Responses

<ResponseField name="error" type="string">
  Error type
</ResponseField>

<ResponseField name="message" type="string">
  Detailed error message
</ResponseField>

### Common Errors

* `400 Bad Request`: Invalid image URL or missing required parameters
* `401 Unauthorized`: Invalid or missing API key
* `429 Too Many Requests`: Rate limit exceeded
* `500 Internal Server Error`: Server error processing the request
