Skip to main content
Anchor Browser delivers a state-of-the-art 89% Score on the industry-standard benchmark WebVoyager, leveraging browser-use as a core component of the automation capability.

The browser AI object

Anchor Browser comes with an embedded AI component, that allows to control the browser or extract data using natural language. This capability allows to use the browser without any coding. For basic usage, the Perform Web Task Tool exposes these capabilities through a single API request. For advanced usage, use it through the playwright CDP connection (all languages supported by PW are supported)

Quick Start Example

Here’s a simple example of using the AI object to perform a web task:
import { chromium } from "playwright-core";
import Anchorbrowser from "anchorbrowser";

(async () => {
const anchorClient = new Anchorbrowser();
const session = await anchorClient.sessions.create({
    apiKey: process.env.ANCHORBROWSER_API_KEY,
});
const cdpUrl = session?.data?.cdp_url;
const browser = await chromium.connectOverCDP(cdpUrl);
const context = browser.contexts()[0];
const ai = context.serviceWorkers()[0];
const page = context.pages()[0];

await page.goto("https://example.com");
const result = await ai.evaluate('What is the main heading on this page?');

await page.close();
console.log(result);
})();

LLM Models

Anchor Browser supports multiple AI providers and models. You can specify which model to use by passing the model parameter to the AI object.

Available Models

Using Different Models

You can specify different models and providers by passing the model parameter:
import { chromium } from "playwright-core";
import Anchorbrowser from "anchorbrowser";

(async () => {
const anchorClient = new Anchorbrowser();
const session = await anchorClient.sessions.create({
    apiKey: process.env.ANCHORBROWSER_API_KEY,
});
const cdpUrl = session?.data?.cdp_url;
const browser = await chromium.connectOverCDP(cdpUrl);
const context = browser.contexts()[0];
const ai = context.serviceWorkers()[0];
const page = context.pages()[0];

// Use OpenAI GPT-5
await page.goto("http://docs.anchorbrowser.io/", {waitUntil:'domcontentloaded'});
const result1 = await ai.evaluate(JSON.stringify({
    prompt: 'Find the last game played by Milwaukee in the NBA and return the result',
    model: 'gpt-5',
    provider: 'openai'
}));
console.log('GPT-5 result:', result1);

// Use Gemini 2.5 Flash
const result2 = await ai.evaluate(JSON.stringify({
    prompt: 'Find the last game played by Milwaukee in the NBA and return the result',
    model: 'gemini-2.5-flash',
    provider: 'gemini'
}));
console.log('Gemini result:', result2);

// Use Groq powered model
const result3 = await ai.evaluate(JSON.stringify({
    prompt: 'Find the last game played by Milwaukee in the NBA and return the result',
    model: 'openai/gpt-oss-120b',
    provider: 'groq'
}));

await page.close();
console.log('Groq result:', result3);
})();

Structured Output

The AI object can also be used to extract structured data from the browser. This is done by providing a JSON schema to the AI object, which will then return the structured data. The following demonstrates using Zod and Pydantic to utilize the structured output capability.
import { chromium } from 'playwright';
import { z } from "zod";
import Anchorbrowser from "anchorbrowser";

(async () => {
  const anchorClient = new Anchorbrowser();
  const session = await anchorClient.sessions.create({
      apiKey: process.env.ANCHORBROWSER_API_KEY,
  });
  const cdpUrl = session?.data?.cdp_url;
  const browser = await chromium.connectOverCDP(cdpUrl);
  const context = browser.contexts()[0];
  const ai = context.serviceWorkers()[0];
  const page = context.pages()[0];

  const outputSchema = z.object({
      nodes_cpu_usage: z.array(
        z.object({
          node: z.string(),
          cluster: z.string(),
          cpu_avg_percentage: z.number(),
        })
      )
  });
  const jsonSchema = z.toJSONSchema(outputSchema);
  const taskPayload = {
    output_schema: jsonSchema,
    prompt: 'Collect the node names and their CPU average %',
  };

  await page.goto("https://play.grafana.org/a/grafana-k8s-app/navigation/nodes?from=now-1h&to=now&refresh=1m");

  const result = await ai.evaluate(JSON.stringify(taskPayload));

  console.info(result);
  await browser.close();
})();
I