Skip to main content
The /image/alt endpoint accepts up to 10 image URLs and returns concise alt text for each one. By default the response is synchronous - results are returned in the same HTTP response, not via polling. Set "sync": false to queue the task asynchronously and receive a 202 with a task ID instead.

Pricing

/image/alt is priced at $0.0004 per image. Only images that successfully receive alt text are charged. The full amount for all submitted URLs is reserved up front. If a URL fails, the unused reserve for that image is released.

Generate alt text with the SDK

import Mynth from "@mynthio/sdk";

const mynth = new Mynth();

const result = await mynth.image.alt({
  urls: ["https://example.com/photo.webp"],
});

console.log(result.getAltTexts());
getAltTexts() returns only successful items. Use getErrors() to inspect failed URLs.
for (const item of result.results) {
  if (item.status === "failed") {
    console.error("Failed to generate alt text:", item.url, item.error.code);
  } else {
    console.log(item.url, item.alt);
  }
}

Generate alt text with REST

curl https://api.mynth.io/image/alt \
  -X POST \
  -H "Authorization: Bearer $MYNTH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "urls": [
      "https://example.com/photo-1.webp",
      "https://example.com/photo-2.webp"
    ]
  }'
Response:
{
  "data": {
    "task": {
      "id": "tsk_01KE7XWWEQ4MCGWKBQKJ1G47RP",
      "status": "completed",
      "cost": "0.00080000"
    },
    "results": [
      {
        "status": "success",
        "url": "https://example.com/photo-1.webp",
        "alt": "A ceramic mug on a wooden table beside a window."
      },
      {
        "status": "success",
        "url": "https://example.com/photo-2.webp",
        "alt": "A red hiking backpack on a rocky mountain trail."
      }
    ]
  }
}

Start now, wait later

Use altAsync() in the SDK when you want to create the task now and wait later:
const task = await mynth.image.altAsync({
  urls: ["https://example.com/photo.webp"],
});

console.log(task.id);

const result = await task.wait();
console.log(result.getAltTexts());
For REST, set "sync": false:
{
  "urls": ["https://example.com/photo.webp"],
  "sync": false
}
The API returns a 202 pending response with a task ID. Poll /tasks/:id/status and /tasks/:id/result, or listen for the task.image.alt.completed webhook.