Skip to main content
POST
/
v1
/
search
Python
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())
async function imageUrlToBase64(imageUrl) {
try {
// Fetch the image as a Blob
const response = await fetch(imageUrl);

if (!response.ok) {
throw new Error(`Failed to fetch image. Status code: ${response.status}`);
}

// Convert the response to a base64 encoded string
const blob = await response.blob();
const reader = new FileReader();

return new Promise((resolve, reject) => {
reader.onloadend = () => resolve(`data:image/jpeg;base64,${reader.result.split(',')[1]}`);
reader.onerror = reject;
reader.readAsDataURL(blob);
});
} catch (error) {
console.error("Error converting image to base64:", error);
}
}

async function sendData() {
const imageUrl = "https://cdn.britannica.com/95/94195-050-FCBF777E/Golden-Gate-Bridge-San-Francisco.jpg";
const base64StringEncodedImage = await imageUrlToBase64(imageUrl);

const url = 'https://api.critique-labs.ai/v1/search';
const headers = {
'Content-Type': 'application/json',
'X-API-Key': 'REPLACE_KEY_VALUE'
};
const data = {
image: base64StringEncodedImage, // Optional arg. Preferred method of sending image instead of url
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 arg. Structured response format
};

try {
const response = await fetch(url, {
method: 'POST',
headers: headers,
body: JSON.stringify(data)
});

if (!response.ok) {
throw new Error(`Request failed with status code ${response.status}: ${await response.text()}`);
}

const responseData = await response.json();
console.log(responseData);
} catch (error) {
console.error("Error sending data:", error);
}
}
curl -X POST https://api.critique-labs.ai/v1/search   -H "Content-Type: application/json"   -H "X-API-Key: REPLACE_KEY_VALUE"   -d '{
"image": "https://cdn.britannica.com/95/94195-050-FCBF777E/Golden-Gate-Bridge-San-Francisco.jpg",
"prompt": "how much are flights to this place from Hong Kong right now",
"source_blacklist": ["expedia.com"],
"output_format": {
"flights": [{"origin": "string", "airline": "string","destination": "string", "price": "number"}],
"response": "string"
}
}'
const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: '<string>',
image: '<string>',
output_format: {},
source_blacklist: [],
source_whitelist: []
})
};

fetch('https://api.critique-labs.ai/v1/search', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.critique-labs.ai/v1/search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => '<string>',
'image' => '<string>',
'output_format' => [

],
'source_blacklist' => [

],
'source_whitelist' => [

]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.critique-labs.ai/v1/search"

payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"image\": \"<string>\",\n \"output_format\": {},\n \"source_blacklist\": [],\n \"source_whitelist\": []\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.critique-labs.ai/v1/search")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"image\": \"<string>\",\n \"output_format\": {},\n \"source_blacklist\": [],\n \"source_whitelist\": []\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.critique-labs.ai/v1/search")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"<string>\",\n \"image\": \"<string>\",\n \"output_format\": {},\n \"source_blacklist\": [],\n \"source_whitelist\": []\n}"

response = http.request(request)
puts response.read_body
{
  "response": "<string>",
  "context": [],
  "info": {}
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}

Authorizations

X-API-Key
string
header
required

Your API key for authentication. Get one at https://critique-labs.ai/en/dashboard

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
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

Successful Response

response
string
required
context
SearchContext · object[]
info
Info · object | null