---
title: "Generate alternative text for an image"
method: POST
path: "/media/{id}/alt-text/generate"
tags: ["Media"]
---

# Generate alternative text for an image

`POST /media/{id}/alt-text/generate`

## Request

- Base URL: `https://app.openpo.st/api/v1`
- URL: `https://app.openpo.st/api/v1/media/{id}/alt-text/generate`
- Auth: one of:
  - HTTP bearer
  - API key in cookie `openpost_session`

Generates alternative text from the stored 400-pixel JPEG thumbnail and optional post text used as untrusted context, then saves it only when the media still has no alternative text.

## Path parameters

- `id` string, required: Media ID

## Request body

- GenerateMediaAltTextInputBody
  - `$schema` string, uri: A URL to the JSON Schema for this object.
  - `locale` string: BCP 47 locale for the generated alt text; defaults to English
  - `post_context` string: Optional post text used only to disambiguate details visible in the image

## Response `200`

OK

- GenerateMediaAltTextOutputBody
  - `$schema` string, uri: A URL to the JSON Schema for this object.
  - `alt_text` string, required: Persisted alternative text
  - `generated` boolean, required: Whether this request generated and persisted new alternative text
  - `model` string, required: Model that generated the alternative text; empty when existing text was returned

## Other responses

- `400`: Bad Request
- `403`: Forbidden
- `404`: Not Found
- `422`: Unprocessable Entity
- `429`: Too Many Requests
- `500`: Internal Server Error
- `502`: Bad Gateway
- `503`: Service Unavailable

---

[API](https://skmtc.dev/openpo/apis/openpost-api.md) · [All operations](https://skmtc.dev/openpo/apis/openpost-api/llms.txt) · [OpenAPI document](https://skmtc.dev/openpo/apis/openpost-api/revisions/67d3964458a7?raw)
