Query

NodeJS

const html = await getHTML("https://www.amazon.com/dp/B01LR5S6HK");

if (!html) return;

const ai = new AIService(cloudBrowserToken, {
    openAIConfiguration: { apiKey: openAiToken },
});

// Response format can be created manually but it is easier to use a type
// await ai.query({
//     html: html,
//     prompt: "Give me the lowest price",
//     responseFormat: JSON.stringify({ response: "number", required: ["response"] })
// });

const rpai = await ai.query({
    html: html,
    prompt: "Give me the lowest price",
});

console.log("The lowest price is:", rpai);

/api/v1/ai/Query – Process an HTML Document and Prompt

Description: This endpoint allows you to send an HTML document and a custom prompt to OpenAI for processing.

Method: POST

Parameters:

  • html: (string) – The HTML document you want to process.

  • prompt: (string) – The custom instruction or task for processing the HTML content.

  • responseFormat: (string) – The desired format of the response (e.g., text, json).

Request Example:

curl -X POST https://production.cloudbrowser.ai/api/v1/ai/Query \
-H "Content-Type: application/json" \
-d '{
  "html": "<html>...</html>",
  "prompt": "Extract the title and summarize the content",
  "responseFormat": "text"
}'

Last updated