> ## Documentation Index
> Fetch the complete documentation index at: https://browseruse-0aece648-agency-v4-agentmail-2fa-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Run a task

> Give a high-accuracy browser agent a goal and get the result.

Create an [API key](https://cloud.browser-use.com/settings?tab=api-keys\&new=1) and export it:

```bash theme={null}
export BROWSER_USE_API_KEY=your_key
```

<CodeGroup>
  ```python Python theme={null}
  from browser_use_sdk.v4 import BrowserUse

  with BrowserUse() as client:
      run = client.runs.create("Find the top Hacker News story")
      result = client.runs.wait_for_completion(run.id)
      print(result.result)
  ```

  ```typescript TypeScript theme={null}
  import { BrowserUse } from "browser-use-sdk/v4";

  const client = new BrowserUse();
  const run = await client.runs.create({
    task: "Find the top Hacker News story",
  });
  const result = await client.runs.waitForCompletion(run.id);
  console.log(result.result);
  ```

  ```bash curl theme={null}
  curl https://api.browser-use.com/api/v4/runs \
    -H "X-Browser-Use-API-Key: $BROWSER_USE_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"task":"Find the top Hacker News story"}'
  ```
</CodeGroup>

Install the latest SDK with `pip install --upgrade browser-use-sdk` or
`npm install browser-use-sdk@latest`. Curl needs no installation.

Every new run implicitly creates a [session](/cloud/agent/sessions) for its
conversation and live browser, plus a [workspace](/cloud/agent/workspaces) for
persistent files.

## Verify an account by email

Set `agentmail` to give the V4 agent its own inbox. The agent can use that
address for a signup, read the verification email, and enter the code:

<CodeGroup>
  ```python Python theme={null}
  from browser_use_sdk.v4 import BrowserUse

  with BrowserUse() as client:
      run = client.runs.create(
          "Create an account at example.com with your inbox. Read the verification email and enter its code.",
          agentmail=True,
      )
  ```

  ```typescript TypeScript theme={null}
  import { BrowserUse } from "browser-use-sdk/v4";

  const client = new BrowserUse();
  const run = await client.runs.create({
    task: "Create an account at example.com with your inbox. Read the verification email and enter its code.",
    agentmail: true,
  });
  ```

  ```bash curl theme={null}
  curl https://api.browser-use.com/api/v4/runs \
    -H "X-Browser-Use-API-Key: $BROWSER_USE_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"task":"Create an account at example.com with your inbox. Read the verification email and enter its code.","agentmail":true}'
  ```
</CodeGroup>

See [2FA](/cloud/guides/2fa) for existing accounts, SMS forwarding, saved
profiles, and human takeovers.

<img src="https://mintcdn.com/browseruse-0aece648-agency-v4-agentmail-2fa-docs/WVxxRUAoaJcRFY46/cloud/images/v4-agent-overview-light.svg?fit=max&auto=format&n=WVxxRUAoaJcRFY46&q=85&s=c2b6500eeca847e5f0e895043f67b408" alt="A task starts a run inside a session and the run reads and writes persistent workspace files" noZoom className="block dark:hidden" width="1200" height="420" data-path="cloud/images/v4-agent-overview-light.svg" />

<img src="https://mintcdn.com/browseruse-0aece648-agency-v4-agentmail-2fa-docs/WVxxRUAoaJcRFY46/cloud/images/v4-agent-overview-dark.svg?fit=max&auto=format&n=WVxxRUAoaJcRFY46&q=85&s=45ada0be175528bd1b8e24abffd7b9fd" alt="A task starts a run inside a session and the run reads and writes persistent workspace files" noZoom className="hidden dark:block" width="1200" height="420" data-path="cloud/images/v4-agent-overview-dark.svg" />

<CardGroup cols={2}>
  <Card title="Copy API V4 docs" icon="sparkles" href="/cloud/llms.txt">
    Give the compact context file to your coding agent.
  </Card>
</CardGroup>
