Created
June 24, 2025 00:24
-
-
Save symisc/4d45bbca1cce6dd9ef4bde16dd7f22bc to your computer and use it in GitHub Desktop.
Get natural language responses to image-related queries using the PixLab query endpoint - https://pixlab.io/endpoints/query
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
# Get natural language responses to image-related queries | |
# 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/query',params={ | |
'img':img, | |
'key':key, | |
'lang':'english', | |
'query':'What does this image depict? Can you guess the location where it was taken?' | |
}) | |
reply = req.json() | |
if reply['status'] != 200: | |
print (reply['error']) | |
else: | |
response = reply['response'] | |
print(f"Query Response: {response}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment