Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
langchain example and docs
Gregor Žuničc82e0b3c5fdc
diff --git a/browser_use/llm/README.md b/browser_use/llm/README.mdnew file mode 100644index 000000000..fedce4fe6--- /dev/null+++ b/browser_use/llm/README.md@@ -0,0 +1,16 @@+# Browser Use LLMs++We officially support the following LLMs:++- OpenAI+- Anthropic+- Groq+- Ollama+- DeepSeek++## Migrating from LangChain++Because of how we implemented the LLMs, we can technically support anything. If you want to use a LangChain model, you can use the `ChatLangchain` (NOT OFFICIALLY SUPPORTED) class.++You can find all the details in the [LangChain example](examples/models/langchain/example.py). We suggest you grab that code and use it as a reference.diff --git a/docs/customize/supported-models.mdx b/docs/customize/supported-models.mdxindex 8d327ae90..309434a65 100644--- a/docs/customize/supported-models.mdx+++ b/docs/customize/supported-models.mdx@@ -12,9 +12,11 @@ Here's how to configure the models.We have recently switched from Langchain to our own implementation of the models. To migrate the previous code, just replace `from langchain_openai import ChatOpenAI` with `from browser_use.llm import ChatOpenAI` etc. The methods should be compatible(ish).+We also made and example [here](https://github.com/browser-use/browser-use/blob/main/examples/models/langchain) to help you stay with Langchain in case your workflow requires it.+## Model Recommendations-We recommend using GPT-4.1 for the best performance (best accuracy ~$0.01 per step). The best price to performance can be achieved using `gemini-2.0-flash-exp` (currently also the most popular model, costs ~$0.001 per step).+We recommend using GPT-4.1 for the best performance (best accuracy around $0.01 per step). The best price to performance can be achieved using `gemini-2.0-flash-exp` (currently also the most popular model, costs around $0.001 per step).## Supported Modelsdiff --git a/examples/models/langchain/README.md b/examples/models/langchain/README.mdindex dfb980fe7..52eb6880d 100644--- a/examples/models/langchain/README.md+++ b/examples/models/langchain/README.md@@ -1,3 +1,33 @@# Langchain Models (legacy)This directory contains example of how to still use Langchain models with the new Browser Use chat models.++## How to use++```python+from langchain_openai import ChatOpenAI++from browser_use import Agent+from .chat import ChatLangchain++async def main():+ """Basic example using ChatLangchain with OpenAI through LangChain."""++ # Create a LangChain model (OpenAI)+ langchain_model = ChatOpenAI(+ model='gpt-4o-mini',+ temperature=0.1,+ )++ # Wrap it with ChatLangchain to make it compatible with browser-use+ llm = ChatLangchain(chat=langchain_model)++ agent = Agent(+ task="Go to google.com and search for 'browser automation with Python'",+ llm=llm,+ )++ history = await agent.run()++ print(history.history)+```