PixQuery API Guide

Image Captioning 📷

/caption

Get your api keys from the API dashboard.

Here are some code snippets in different languages on how to use the captioning API.

Replace <your-api-key> with your API key and <image-base64-string> with your image’s base64 string.

Visual Question Answering ❓

/ask

  1. The API Keys for the caption and ask endpoints are same (for now). Get your API keys from the dashboard.

Here are some code snippets in different languages on how to use the VQA API.

Replace <your-api-key> with your API key and <image-base64-string> with your image’s base64 string and <question> with the question you want to ask the image.

Python 🐍 Example →

from PIL import Image

#read the image
im = Image.open("image.jpg")

#show image
display(im)

import base64
import requests

with open('image.jpg', 'rb') as image_file:
    encoded_string = base64.b64encode(image_file.read()).decode("utf-8")

api_key = '3imw41hnSONtdWG0Swqkxg'
headers = {
    'accept': 'application/json',
    'apikey': api_key,
    'Content-Type': 'application/json',
}

json_data = {
    'image': encoded_string,
}

response = requests.post('https://api.pixquery.com/caption', headers=headers, json=json_data)

response.text