> ## Documentation Index
> Fetch the complete documentation index at: https://browser-use.mingxi.ltd/llms.txt
> Use this file to discover all available pages before exploring further.

# 快速入门

> 通过这个快速入门指南开始使用 Browser Use

## 准备环境

Browser Use 需要 Python 3.11 或更高版本。

首先，我们建议使用 [uv](https://docs.astral.sh/uv/) 来设置 Python 环境。

```bash theme={null}
uv venv --python 3.11
```

然后激活它:

```bash theme={null}
# Mac/Linux:
source .venv/bin/activate

# Windows:
.venv\Scripts\activate
```

安装依赖:

```bash theme={null}
uv pip install browser-use
```

然后安装 playwright:

```bash theme={null}
playwright install
```

## 创建代理

然后你可以按如下方式使用代理:

```python agent.py theme={null}
from langchain_openai import ChatOpenAI
from browser_use import Agent
from dotenv import load_dotenv
load_dotenv()

import asyncio

llm = ChatOpenAI(model="gpt-4o")

async def main():
    agent = Agent(
        task="比较 gpt-4o 和 DeepSeek-V3 的价格",
        llm=llm,
    )
    result = await agent.run()
    print(result)

asyncio.run(main())
```

## 设置 LLM API 密钥

`ChatOpenAI` 和其他 Langchain 聊天模型需要 API 密钥。你应该将这些存储在 `.env` 文件中。例如，对于 OpenAI 和 Anthropic，你可以在 `.env` 文件中设置 API 密钥，如:

```bash .env theme={null}
OPENAI_API_KEY=
ANTHROPIC_API_KEY=
```

对于其他 LLM 模型，你可以参考 [Langchain 文档](https://python.langchain.com/docs/integrations/chat/) 来了解如何使用它们特定的 API 密钥进行设置。
