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
moved llm api env vars dict to agent views
Anish Hiranandani45ab623bff36
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.pyindex d24f147fc..b32d9646f 100644--- a/browser_use/agent/service.py+++ b/browser_use/agent/service.py@@ -38,6 +38,7 @@ from browser_use.agent.views import (AgentStepInfo,StepMetadata,ToolCallingMethod,+ REQUIRED_LLM_API_ENV_VARS)from browser_use.browser.browser import Browserfrom browser_use.browser.context import BrowserContext@@ -55,7 +56,6 @@ from browser_use.telemetry.views import (AgentStepTelemetryEvent,)from browser_use.utils import time_execution_async, time_execution_sync, check_env_variables-from browser_use.constants import REQUIRED_ENV_VARIABLESload_dotenv()logger = logging.getLogger(__name__)@@ -185,7 +185,7 @@ class Agent(Generic[Context]):self._set_model_names()# Check env setup- llm_api_env_vars = REQUIRED_ENV_VARIABLES[self.llm.__class__.__name__]+ llm_api_env_vars = REQUIRED_LLM_API_ENV_VARS[self.llm.__class__.__name__]if not check_env_variables(llm_api_env_vars):logger.error(f"Environment variables not set for {self.llm.__class__.__name__}")raise ValueError('Environment variables not set')diff --git a/browser_use/agent/views.py b/browser_use/agent/views.pyindex 1cec01f55..2a20f8d98 100644--- a/browser_use/agent/views.py+++ b/browser_use/agent/views.py@@ -22,6 +22,13 @@ from browser_use.dom.history_tree_processor.service import (from browser_use.dom.views import SelectorMapToolCallingMethod = Literal['function_calling', 'json_mode', 'raw', 'auto']+REQUIRED_LLM_API_ENV_VARS = {+ "ChatOpenAI": ["OPENAI_API_KEY"],+ "AzureOpenAI": ["AZURE_ENDPOINT", "AZURE_OPENAI_API_KEY"],+ "ChatBedrockConverse": ["ANTHROPIC_API_KEY"],+ "ChatAnthropic": ["ANTHROPIC_API_KEY"],+ "ChatGoogleGenerativeAI": ["GEMINI_API_KEY"]+}class AgentSettings(BaseModel):