Run natural-language browser tasks with the perform-web-task API and agentTask SDK method.
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.
Anchor Browser provides within its SDK the agentTask method that enables natural language control over web browsing sessions. This capability allows you to automate complex web tasks without coding the whole flow.
import { client, agentTask } from 'anchorbrowser';client.setConfig({ auth: () => process.env.ANCHORBROWSER_API_KEY });const response = await agentTask('Extract the main heading', { taskOptions: { url: 'https://example.com' },});console.log(response.data.result);
from anchorbrowser import Anchorbrowserimport osanchor_client = Anchorbrowser(api_key=os.environ.get("ANCHORBROWSER_API_KEY"))response = anchor_client.agent.task( "Extract the main heading", task_options={"url": "https://example.com"},)print(response.data.result)
The prompt is the only required argument — add url (or sessionId) to point the agent at a page.
Everything else (agent, model, provider, max steps, secret values, …) is optional; see
Configuration Options below.
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 { z } from 'zod';import { zodToJsonSchema } from 'zod-to-json-schema';import { agentTask } from 'anchorbrowser';// Define the expected output structure using Zod schemaconst outputSchema = z.object({ nodes_cpu_usage: z.array( z.object({ node: z.string(), // Node name cluster: z.string(), // Cluster identifier cpu_avg_percentage: z.number(), // CPU usage percentage }) )});// Execute the AI task with structured outputconst result = await agentTask('Collect the node names and their CPU average %', { taskOptions: { outputSchema: zodToJsonSchema(outputSchema), // Convert to JSON Schema url: 'https://play.grafana.org/a/grafana-k8s-app/navigation/nodes?from=now-1h&to=now&refresh=1m', }});console.info(result);
# Define data models using Pydantic for structured outputclass NodeCpuUsage(BaseModel): node: str # Node name cluster: str # Cluster identifier cpu_avg_percentage: float # CPU usage percentageclass OutputSchema(BaseModel): nodes_cpu_usage: List[NodeCpuUsage] # List of node CPU usage data# Create task payload with structured output schematask_payload = { 'prompt': 'Collect the node names and their CPU average %', 'output_schema': OutputSchema.model_json_schema() # Convert to JSON Schema}result = anchor_client.agent.task('Collect the node names and their CPU average %', task_options={ 'output_schema': OutputSchema.model_json_schema(), 'url': 'https://play.grafana.org/a/grafana-k8s-app/navigation/nodes?from=now-1h&to=now&refresh=1m', })print(result)
Securely pass credentials and sensitive data to AI agents during task execution. Secret values are not logged and automatically cleaned up after completion.