Supported Models & Setup
Relevant source files
The following files were used as context for generating this wiki page:
The Supported Models & Setup module defines the integration layer between the Browser Use Web UI and various Large Language Model (LLM) providers. This system enables the AI agent to utilize a diverse range of models, including proprietary APIs and local instances, to process user instructions, analyze browser states, and determine next actions.
The architecture supports multiple providers such as OpenAI, Anthropic, Google, and DeepSeek, alongside local hosting via Ollama. It manages configuration via environment variables or direct UI input, handling model-specific logic like reasoning content extraction for DeepSeek-R1 and context window management for local models.
Sources: README.md:15-18, src/utils/utils.py:42-140
LLM Provider Architecture
The project employs a factory-style pattern to initialize LLM clients using the get_llm_model function. This function abstracts the complexities of different provider SDKs (OpenAI, Anthropic, Google, Mistral, etc.) and returns a unified LangChain compatible chat model object.
The diagram shows the flow from a request to the get_llm_model factory which routes to specific provider implementations.
Sources: src/utils/utils.py:42-138, tests/test_llm_api.py:35-51
Specialized Model Implementations
For models that require custom handling of response metadata (like reasoning chains), the system implements specialized classes. Specifically, DeepSeekR1ChatOpenAI and DeepSeekR1ChatOllama are used to extract "reasoning_content" or content within <think> tags.
- Reasoning Extraction: In
DeepSeekR1ChatOllama, theinvokemethod splits the raw content by the</think>tag to separate the agent's internal reasoning from its final output. - Context Management: For Ollama models, a
num_ctxparameter is utilized to control the maximum context length, which defaults to 32,000 but can be adjusted via the UI.
Sources: src/utils/llm.py:53-128, src/utils/utils.py:108-124
Supported Providers & Models
The following table lists the primary supported providers and their default or common models as defined in the source code.
| Provider | Default/Key Models | Configuration Key | Source |
|---|---|---|---|
| OpenAI | gpt-4o, gpt-4, gpt-3.5-turbo, o3-mini | OPENAI_API_KEY | utils.py:144 |
| Anthropic | claude-3-5-sonnet, claude-3-opus | ANTHROPIC_API_KEY | utils.py:143 |
| gemini-2.0-flash, gemini-1.5-flash | GOOGLE_API_KEY | utils.py:146 | |
| DeepSeek | deepseek-chat, deepseek-reasoner | DEEPSEEK_API_KEY | utils.py:145 |
| Ollama | qwen2.5, llama2, deepseek-r1 | N/A (Local) | utils.py:147 |
| Azure OpenAI | gpt-4o, gpt-4 | AZURE_OPENAI_API_KEY | utils.py:148 |
| Mistral | pixtral-large-latest, mistral-large | MISTRAL_API_KEY | utils.py:149 |
Sources: src/utils/utils.py:142-152, tests/test_llm_api.py:54-62
Setup & Configuration
Configuration is managed through a combination of environment variables and a persistent settings system.
Environment Configuration
Users can define global defaults in a .env file. The application maps these to specific provider settings during initialization.
env_mappings = {
"openai": {"api_key": "OPENAI_API_KEY", "base_url": "OPENAI_ENDPOINT"},
"azure_openai": {"api_key": "AZURE_OPENAI_API_KEY", "base_url": "AZURE_OPENAI_ENDPOINT"},
"google": {"api_key": "GOOGLE_API_KEY"},
"deepseek": {"api_key": "DEEPSEEK_API_KEY", "base_url": "DEEPSEEK_ENDPOINT"}
}
Sources: tests/test_llm_api.py:54-62, README.md:144-150
Web UI Settings
The Web UI provides a configuration tab where users can load and save settings as .pkl files. The default_config function establishes the baseline parameters for the agent and LLM.
- Temperature: Controls randomness (default: 1.0).
- Max Context Length: Specific to local models like Ollama.
- Base URL: Allows redirection to custom endpoints or local proxies (e.g.,
http://localhost:11434for Ollama).
Sources: src/utils/default_config_settings.py:8-32, webui.py:465-490
Initialization Logic
The initialization of the LLM involves resolving the API key, setting the base URL, and instantiating the correct LangChain class.
The sequence diagram illustrates how the get_llm_model function validates inputs and selects the specialized or standard LangChain class.
Sources: src/utils/utils.py:42-140, src/utils/llm.py:53-128
Summary
The "Supported Models & Setup" system provides a robust abstraction layer for LLM integration. By combining standard LangChain classes with custom extensions for DeepSeek reasoning and Ollama context management, it ensures that the browser agent can operate across a wide spectrum of AI backends. Configuration is flexible, allowing for quick deployment via environment variables or granular control through the Gradio-based Web UI.