Skip to content

Instantly share code, notes, and snippets.

@greg-randall
Created September 6, 2023 18:51
Show Gist options
  • Save greg-randall/8581eec1bb492d1fe107fbd17d49da8b to your computer and use it in GitHub Desktop.
Save greg-randall/8581eec1bb492d1fe107fbd17d49da8b to your computer and use it in GitHub Desktop.
Quick curl to get alt text for an image using https://alttext.ai/. Create an account to get an API key.
curl https://alttext.ai/api/v1/images \
-s \
-X POST \
--header "X-Api-Key:API-KEY" \
-H 'Content-Type: application/json' \
-d "$( printf "{ \"image\": { \"raw\": \"$(base64 test.jpg)\" } }" )" \
| jq \
| grep -i alt_text \
| perl -pe 's/^[^"]*"[^"]*"[^"]*"([^"]*)".+/$1/i'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment