# Image Caption and Alt Text Generator in bulk (`examsens.ai/image-caption-alt-text`) Actor

Writes short alt text and a longer caption for every image URL you list with Florence-2, running inside the actor with no outside API. Set a character limit for each, and optionally read the text printed in the image.

- **URL**: https://apify.com/examsens.ai/image-caption-alt-text.md
- **Developed by:** [Ed Rayyis](https://apify.com/examsens.ai) (community)
- **Categories:** AI, SEO tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $12.00 / 1,000 image describeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Image Caption and Alt Text Generator in bulk

Give it a list of image URLs and it writes two descriptions for each one: short alt text for the `alt` attribute and a longer caption. It can also read the words printed in the image. The vision model, Florence-2, runs inside the actor, so your images go to no outside API and there is no key to set up.

### What it does

- Alt text in one short sentence, trimmed to the character limit you set (125 by default). When it has to trim, it cuts at a phrase boundary, so you get "A view of a mountain range." and not a sentence that stops mid phrase. The untrimmed version comes back too.
- Caption in two styles. Detailed gives one or two sentences. Paragraph gives a longer description, with more detail and more room for mistakes. Set a caption limit and it keeps the whole sentences that fit.
- Text in the image if you ask: the words on signs, labels and banners. A plain sign reading "Grand Opening Sale" came back as exactly that.
- Turns photos upright from their EXIF orientation first.
- Handles many images in one run. Each image gets its own result, and one bad link never stops the run.

Descriptions are in English. Reads JPEG, PNG, WebP, GIF, BMP, TIFF and the other formats Pillow reads. An animated GIF is described from its first frame, and the item says so in `note`.

### Example

For a photo of a black puppy on a wooden deck, the alt text was "A black puppy standing on a wooden floor." With a 40 character limit it became "A black puppy standing." For a mountain photo, the detailed caption was "The image shows mountains. In the background there is sky with clouds."

Review descriptions before you publish them. The model can miss context or name the wrong detail, and the paragraph style does so more often.

### Input

- Image URLs (required)
- Alt text character limit (default 125)
- Caption style: detailed (default) or paragraph
- Caption character limit (default 0, no limit)
- Read text in the image (default off)
- Maximum file size in MB (default 25)

### Output

Dataset: one item per URL with `altText`, `altTextLength`, `caption`, `captionLength`, `imageText` when you ask for it, `width`, `height`, `inputFormat` and `processingSeconds`. When a limit trims a description, `altTextUntrimmed` or `captionUntrimmed` holds the full version.

A URL that cannot be described gets `ok: false` and an `error`, such as `HTTP 404`, an unknown host, a file over the size limit, or "the file is not an image format this actor can read" for a web page.

### Speed

The model runs on the CPU. At the default 4 GB of memory, with text reading on, each image took 12 to 13 seconds.

### Model and license

Florence-2 base ft, by Microsoft, released under the MIT License, run from the ONNX export in the onnx-community repository on Hugging Face. Generation uses the model's own settings: three beams and no repeated three word sequences.

### Pricing

Pay per event: one event per image described. URLs that fail are not charged. The run stops when it reaches the maximum charge you set.

### Scope and conduct

Only the URLs you supply are downloaded. The actor does not log in anywhere and uses no proxies.

### Support

Questions and problems: the Issues tab on this page. Replies are written by an AI assistant on behalf of the developer and reviewed by the developer.

# Actor input Schema

## `imageUrls` (type: `array`):

Direct links to image files (JPEG, PNG, WebP, GIF, BMP, TIFF and other formats Pillow reads).

## `altTextMaxChars` (type: `integer`):

Longer alt text is trimmed at a word end. 125 is a common guideline for screen readers.

## `captionStyle` (type: `string`):

Detailed gives one or two sentences. Paragraph gives a longer description with more detail, and more room for mistakes.

## `captionMaxChars` (type: `integer`):

Longer captions are trimmed to whole sentences that fit. 0 means no limit.

## `includeImageText` (type: `boolean`):

Also return the words printed in the image, such as signs, labels and headlines.

## `maxFileSizeMb` (type: `integer`):

Skip source files larger than this, with an error item.

## Actor input object example

```json
{
  "imageUrls": [
    {
      "url": "https://picsum.photos/id/237/800/600"
    }
  ],
  "altTextMaxChars": 125,
  "captionStyle": "detailed",
  "captionMaxChars": 0,
  "includeImageText": false,
  "maxFileSizeMb": 25
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "imageUrls": [
        {
            "url": "https://picsum.photos/id/237/800/600"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("examsens.ai/image-caption-alt-text").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "imageUrls": [{ "url": "https://picsum.photos/id/237/800/600" }] }

# Run the Actor and wait for it to finish
run = client.actor("examsens.ai/image-caption-alt-text").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "imageUrls": [
    {
      "url": "https://picsum.photos/id/237/800/600"
    }
  ]
}' |
apify call examsens.ai/image-caption-alt-text --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,examsens.ai/image-caption-alt-text"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/ZgUVS1A2tyJjRgugX/builds/amXHKVDGy6ekzaMmW/openapi.json
