browser-use
browser-use copied to clipboard
Interaction Issue: ...Tool calling method 'raw' test failed: AuthenticationError: Error code: 401
Browser Use Version
0.2.5
LLM Model
deepseek-chat
Screenshots, Description, and task prompt given to Agent
when i make http request with api_key is success
but when i use browseruse with the same api_key to make connet to LLM is fail
HTML around where it's failing
-
Operating System & Browser Versions
win11
Python Code Sample
import asyncio
import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
from dotenv import load_dotenv
load_dotenv()
from langchain_deepseek import ChatDeepSeek
from langchain_openai import ChatOpenAI
from pydantic import SecretStr
from browser_use import Agent
from browser_use import Browser ,BrowserConfig
api_key = os.getenv('DEEPSEEK_API_KEY', '')
if not api_key:
raise ValueError('DEEPSEEK_API_KEY is not set')
config = BrowserConfig(
headless=False,
disable_security=True,
chrome_instance_path="C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"
)
browser = Browser(config=config)
async def run_search():
agent = Agent(
task="go to https://www.baidu.com",
llm=ChatDeepSeek(
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
model='deepseek-r1',
api_key='sk-****',
timeout=60
),
browser=browser,
use_vision=False,
)
print("Agent 初始化完成") # 检查是否卡在 Agent 初始化
history = await agent.run()
print("任务执行完成") # 检查是否卡在 agent.run()
result = history.final_result()
print("执行结果", result)
history = await agent.run()
if __name__ == '__main__':
asyncio.run(run_search())
Full DEBUG Log Output
DEBUG [agent] Version: v0.2.5, Source: pip
DEBUG [agent] 🛠️ Tool calling method 'raw' test failed: AuthenticationError: Error code: 401 - {'error': {'message': 'Authentication Fails, Your api key: ****996a is invalid', 'type': 'authentication_error', 'param': None, 'code': 'invalid_request_error'}}
DEBUG [agent] Known method raw failed for ChatDeepSeek/deepseek-r1, falling back to detection
DEBUG [agent] 🛠️ Tool calling method 'tools' test failed: ValueError: Unrecognized method argument. Expected one of 'function_calling' or 'json_mode'. Received: 'tools'
DEBUG [agent] 🛠️ Tool calling method 'raw' test failed: AuthenticationError: Error code: 401 - {'error': {'message': 'Authentication Fails, Your api key: ****996a is invalid', 'type': 'authentication_error', 'param': None, 'code': 'invalid_request_error'}}
DEBUG [agent] 🛠️ Tool calling method 'json_mode' test failed: AuthenticationError: Error code: 401 - {'error': {'message': 'Authentication Fails, Your api key: ****996a is invalid', 'type': 'authentication_error', 'param': None, 'code': 'invalid_request_error'}}
DEBUG [agent] 🛠️ Tool calling method 'function_calling' test failed: AuthenticationError: Error code: 401 - {'error': {'message': 'Authentication Fails, Your api key: ****996a is invalid', 'type': 'authentication_error', 'param': None, 'code': 'invalid_request_error'}}
Traceback (most recent call last):
File "C:\Users\GM489XR\OneDrive - CHINA\Desktop\automation\AI_TEST\AI_deepseek_r1.py", line 62, in <module>
asyncio.run(run_search())
~~~~~~~~~~~^^^^^^^^^^^^^^
File "C:\Users\GM489XR\AppData\Local\Programs\Python\Python313\Lib\asyncio\runners.py", line 195, in run
return runner.run(main)
~~~~~~~~~~^^^^^^
File "C:\Users\GM489XR\AppData\Local\Programs\Python\Python313\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "C:\Users\GM489XR\AppData\Local\Programs\Python\Python313\Lib\asyncio\base_events.py", line 719, in run_until_complete
return future.result()
~~~~~~~~~~~~~^^
File "C:\Users\GM489XR\OneDrive - EY CHINA\Desktop\automation\AI_TEST\AI_deepseek_r1.py", line 35, in run_search
agent = Agent(
task="go to https://www.baidu.com",
...<11 lines>...
)
File "C:\Users\GM489XR\AppData\Local\Programs\Python\Python313\Lib\site-packages\browser_use\utils.py", line 311, in wrapper
result = func(*args, **kwargs)
File "C:\Users\GM489XR\AppData\Local\Programs\Python\Python313\Lib\site-packages\browser_use\agent\service.py", line 214, in __init__
self._verify_and_setup_llm()
~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "C:\Users\GM489XR\AppData\Local\Programs\Python\Python313\Lib\site-packages\browser_use\agent\service.py", line 1775, in _verify_and_setup_llm
self.tool_calling_method = self._set_tool_calling_method()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "C:\Users\GM489XR\AppData\Local\Programs\Python\Python313\Lib\site-packages\browser_use\agent\service.py", line 754, in _set_tool_calling_method
return self._detect_best_tool_calling_method()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "C:\Users\GM489XR\AppData\Local\Programs\Python\Python313\Lib\site-packages\browser_use\agent\service.py", line 646, in _detect_best_tool_calling_method
raise ConnectionError('Failed to connect to LLM. Please check your API key and network connection.')
ConnectionError: Failed to connect to LLM. Please check your API key and network connection.
{'message': 'Authentication Fails, Your api key: ****996a is invalid'
hi, do you resole this question, i have the same experience.