# Query

### NodeJS

```javascript
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);
```

### .NET

```csharp
var html = await GetHTML("http://www.cloudbrowser.ai").ConfigureAwait(false);

if (html == null) return;

using AIService ai = new(cloudBrowserToken, openAiToken);

var rpai = await ai.Query<decimal>(new() {
    Html = html,
    Prompt = "Give me the lowest price"
}).ConfigureAwait(false);

Console.WriteLine("The lowest price is: {0}", rpai);
```

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

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

```bash
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"
}'
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cloudbrowser.gitbook.io/docs/configurations/ai-functions/query.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
