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
prompt
string
required

The search query, can be as extended or succinct as you like

image
string | null

Optional, This string can be the url of the image you want to send. Alternatively, (and the preferred method) is providing a base64 encoded string of the image. If providing a url, the link must start with https:// and ends with a common image file extension like .jpg, .jpeg, .png, .gif, etc.

output_format
object | null

Optional, a json schema for the response. This will be used to format the response of the agentic search. The types allowed can be any of: string number boolean integer array

source_blacklist
string[] | null

Optional, a list of strings representing domains you want to exclude from the agentic search. ['cnn.com','foxnews.com'].

source_whitelist
string[] | null

Optional, a list of strings representing domains you want to include in the agentic search. ['cnn.com','foxnews.com']. This is mutually exclusive with source_blacklist, if it is not empty, source_blacklist must be empty

Response

200
application/json
Successful Response
response
string
required
context
object[]
info
object | null