Skip to content

Instantly share code, notes, and snippets.

@symisc
Created June 22, 2025 23:46
Show Gist options
  • Save symisc/fcf333524c9b339fc235d12ee1a5871e to your computer and use it in GitHub Desktop.
Save symisc/fcf333524c9b339fc235d12ee1a5871e to your computer and use it in GitHub Desktop.
Generate a natural language description of an image content using the PixLab DESCRIBE API Endpoint - https://pixlab.io/endpoints/describe
import requests
import json
# Generate a natural language description of an image content
# Target Image: Change to any link or switch to POST if you want to upload your image directly, refer to the REST API code samples for more info.
img = 'https://s-media-cache-ak0.pinimg.com/originals/35/d0/f6/35d0f6ee0e40306c41cfd714c625f78e.jpg'
key = 'PIXLAB_API_KEY' # Get your API key from https://console.pixlab.io/
req = requests.get('https://api.pixlab.io/describe',params={
'img':img,
'key':key,
'lang':'english',
'short':False
})
reply = req.json()
if reply['status'] != 200:
print (reply['error'])
else:
description = reply['description']
print(f"Natural language content description: {description}")
@symisc
Copy link
Author

symisc commented Jun 22, 2025

https://pixlab.io/api-endpoint for the list of API endpoints and their respective documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment