BrowserUseLLMNotConfiguredError
browser_use.exceptions.BrowserUseLLMNotConfiguredError
Stack trace
Traceback (most recent call last):
File "app.py", line 42, in <module>
browser_use_client.run_query("What is the weather today?")
File "/usr/local/lib/python3.9/site-packages/browser_use/client.py", line 88, in run_query
raise BrowserUseLLMNotConfiguredError("No LLM configured for Browser Use feature.")
browser_use.exceptions.BrowserUseLLMNotConfiguredError: No LLM configured for Browser Use feature. Why it happens
The Browser Use LLM feature requires an LLM client or model to be explicitly configured before use. If the configuration step is skipped or the environment variable for the LLM API key is missing, the system cannot instantiate the LLM client, causing this error.
Detection
Check for the presence of the LLM configuration or API key environment variables before invoking Browser Use LLM calls, and log a clear warning if missing.
Causes & fixes
No LLM client or model configured in the code before calling Browser Use features
Instantiate and assign a valid LLM client or model to the Browser Use configuration before making any calls.
Missing or unset environment variable for the LLM API key required by Browser Use
Set the required environment variable (e.g., OPENAI_API_KEY) with a valid API key before running the application.
Incorrect or incomplete initialization sequence that skips LLM setup
Ensure the initialization code includes proper LLM client setup and that it completes successfully before Browser Use calls.
Code: broken vs fixed
from browser_use import BrowserUseClient
client = BrowserUseClient()
# Missing LLM configuration here
client.run_query("Fetch latest news") # This line raises BrowserUseLLMNotConfiguredError import os
from browser_use import BrowserUseClient
from openai import OpenAI
os.environ["OPENAI_API_KEY"] = os.environ.get("OPENAI_API_KEY", "your_api_key_here") # Set your API key securely
llm_client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
client = BrowserUseClient(llm=llm_client) # Properly configure LLM client
response = client.run_query("Fetch latest news")
print(response) # This works without error Workaround
Wrap Browser Use LLM calls in try/except BrowserUseLLMNotConfiguredError and provide a fallback response or prompt the user to configure the LLM before retrying.
Prevention
Always initialize and configure the LLM client with valid credentials before using Browser Use features, and validate environment variables at application startup.