POST
/
v1
/
search

import requests
import base64

def image_url_to_base64(image_url):
    # Fetch the image from the URL
    response = requests.get(image_url)
    
    # Check if the request was successful
    if response.status_code != 200:
        raise Exception(f"Failed to fetch image. Status code: {response.status_code}")
    
    # Convert the image content to base64
    base64_encoded_image = base64.b64encode(response.content).decode('utf-8')
    
    return f"data:image/jpeg;base64,{base64_encoded_image}"

image_url = "https://cdn.britannica.com/95/94195-050-FCBF777E/Golden-Gate-Bridge-San-Francisco.jpg"
base64_string_encoded_image = image_url_to_base64(image_url)

url = 'https://api.critique-labs.ai/v1/search'
headers = {
    'Content-Type': 'application/json',
    'X-API-Key': 'REPLACE_KEY_VALUE'
}
data = {
    'image': base64_string_encoded_image, ## optional, this is the preferred method of sending an image, though url is also accepted. 
    'prompt': 'how much are flights to this place from Hong Kong right now',
    'source_blacklist': ['expedia.com'], ## optional - specify either source_blacklist or source_whitelist, not both
    # 'source_whitelist': ['kayak.com'], ## optional - specify either source_blacklist or source_whitelist, not both
    'output_format': {'flights': [{"origin": "string", "airline": "string", "destination": "string","price": "number"}], "response": "string"} ## optional. If you want a structured response, you can specify the output format here 

}

# Sending a POST request
response = requests.post(url, headers=headers, json=data)

# Check for any errors
if response.status_code != 200:
    raise Exception(f"Request failed with status code {response.status_code}: {response.text}")

# Print the response body
print(response.json())
{
  "response": "<string>",
  "context": [],
  "info": {}
}

Authorizations

X-API-Key
string
header
required

Body

application/json

Response

200
application/json
Successful Response

The response is of type object.