# LangChain Chat Models

#### Overview <a href="#overview" id="overview"></a>

Scrap Web supports various LangChain chat models. Here’s how to configure and use the most popular ones. The full list is available in the [LangChain documentation](https://python.langchain.com/docs/integrations/chat/).

#### [​](https://docs.browser-use.com/customize/langchain-models#model-recommendations)Model Recommendations <a href="#model-recommendations" id="model-recommendations"></a>

We have yet to test performance across all models. Currently, we recommend using GPT-4o. It achieves 89% accuracy on [WebVoyager Dataset](https://browser-use.com/posts/sota-technical-report).

{% hint style="info" %}
All models require their respective API keys. Make sure to set them in your environment variables before running the agent.
{% endhint %}

#### [​](https://docs.browser-use.com/customize/langchain-models#supported-models)Supported Models <a href="#supported-models" id="supported-models"></a>

All LangChain chat models are supported. We will document the most popular ones here.

[**​**](https://docs.browser-use.com/customize/langchain-models#openai)**OpenAI**

OpenAI’s GPT-4o models are recommended for best performance.

Copy

```
from langchain_openai import ChatOpenAI
from swift_web import Agent

# Initialize the model
llm = ChatOpenAI(
    model="gpt-4o",
    temperature=0.0,
)

# Create agent with the model
agent = Agent(
    task="Your task here",
    llm=llm
)
```

Required environment variables:

.envCopy

```
OPENAI_API_KEY=
```

[**​**](https://docs.browser-use.com/customize/langchain-models#anthropic)**Anthropic**

Claude models provide excellent performance and can handle complex tasks well.

Copy

```
from langchain_anthropic import ChatAnthropic
from swift_web import Agent

# Initialize the model
llm = ChatAnthropic(
    model_name="claude-3-sonnet-20240229",
    temperature=0.0,
    timeout=100, # Increase for complex tasks
)

# Create agent with the model
agent = Agent(
    task="Your task here",
    llm=llm
)
```

And add the variable:

.envCopy

```
ANTHROPIC_API_KEY=
```

[**​**](https://docs.browser-use.com/customize/langchain-models#azure-openai)**Azure OpenAI**

If you’re using Azure OpenAI services, you can configure the model like this:

Copy

```
from langchain_openai import AzureChatOpenAI
from swift_web import Agent
from pydantic import SecretStr
import os

# Initialize the model
llm = AzureChatOpenAI(
    model="gpt-4o",
    api_version='2024-10-21',
    azure_endpoint=os.getenv('AZURE_OPENAI_ENDPOINT', ''),
    api_key=SecretStr(os.getenv('AZURE_OPENAI_KEY', '')),
)

# Create agent with the model
agent = Agent(
    task="Your task here",
    llm=llm
)
```

Required environment variables:

.envCopy

```
AZURE_OPENAI_ENDPOINT=https://your-endpoint.openai.azure.com/
AZURE_OPENAI_KEY=
```

#### [​](https://docs.browser-use.com/customize/langchain-models#coming-soon)Coming soon <a href="#coming-soon" id="coming-soon"></a>

(Sorry, we are working on it)

* Gemini
* Groq
* DeepSeek
* Github
* Ollama
* QWen
