# Starting a Browser Task

A **browser task** in **Browser Swarm** represents a single browser instance running in the cloud. It's the fundamental unit for executing web automation tasks, providing an isolated environment for your operations.

***

### 🛠️ Creating a Browser Task

Browser tasks are initiated through the Sessions API or our SDKs, granting you full control over configuration and features. Upon creation, you'll receive a connection URL to use with your preferred automation framework.

#### Example

{% tabs %}
{% tab title="Node.js" %}

```javascript
import { BrowserSwarm } from 'browser-swarm-sdk';

const bs = new BrowserSwarm({ apiKey: process.env.BROWSER_SWARM_API_KEY });
const session = await bs.sessions.create({
  projectId: process.env.BROWSER_SWARM_PROJECT_ID,
  // Add configuration options here
});
```

{% endtab %}

{% tab title="Python" %}

```python
import os
from browser_swarm import BrowserSwarm

bs = BrowserSwarm(api_key=os.environ["BROWSER_SWARM_API_KEY"])
session = bs.sessions.create(
    project_id=os.environ["BROWSER_SWARM_PROJECT_ID"],
    # Add configuration options here
)
```

{% endtab %}
{% endtabs %}

***

### ⚙️ Configuration Options

When creating a session, you can customize various settings to suit your needs.

#### Basic Settings

* **Region**: Choose where your browser runs to reduce latency.
* **Viewport**: Set custom screen dimensions for your browser window.
* **Keep Alive**: Enable longer-running sessions that persist after disconnection.
* **Recording**: Enable or disable session recording (enabled by default).
* **Logging**: Enable or disable session logging for debugging (enabled by default).

#### Advanced Features

* **Stealth Mode**: Configure anti-bot mitigations, including automatic fingerprinting and advanced stealth options.
* **Proxies**: Set up proxy configurations for your sessions.
* **Captcha Solving**: Enable automatic captcha solving (enabled by default).
* **Extensions**: Load custom browser extensions to enhance functionality.
* **Browser Context**: Configure isolated browsing contexts for session persistence.
* **User Metadata**: Attach custom data for session organization and filtering.

***

### Next Steps

After creating a session, you can:

1. Connect to it using your preferred automation framework.
2. Monitor it through the Session Inspector.
3. End it manually or let it timeout.


---

# 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://browserswarm.gitbook.io/docs/core-concepts/starting-a-browser-task.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.
