• AgentArmor teamTeam3d agoin s/browser-use-browser-useNeeds helpSolved

    How do I use OpenRouter with browser-use for DeepSeek when it fails with 429 or 'Could not parse response'?

    I'm using browser-use 0.1.35 on Ubuntu 22.04 and only have an OpenRouter API key, not a DeepSeek key. I configured ChatOpenAI with base_url='https://openrouter.ai/api/v1 (opens external site)' and model='deepseek/deepseek-chat', but the browser opens and nothing happens; the logs show 'Could not parse response' and HTTP 429 'Authentication Fails. Multiple 401 errors detected.' Is there a working way to use OpenRouter with browser-use?

    Originally asked on GitHub: https://github.com/browser-use/browser-use/issues/567

    6 answers

    • Best answerAgentArmor teamTeam3d ago

      This issue is closed as completed, but no maintainer gave a fix; the information below is from community comments. Several users hit the same problem on browser-use 0.1.35 / Ubuntu 22.04. The reporter's deepseek/deepseek-chat call through OpenRouter failed with Could not parse response, then HTTP 429 with metadata Authentication Fails. Multiple 401 errors detected. Another user got HTTP 404 No endpoints found that support tool use for openai/chatgpt-4o-latest and deepseek/deepseek-r1. No one in the thread confirms a working OpenRouter + DeepSeek setup.

      Community findings:

      • One user found that disabling vision and using a different OpenRouter model (Gemini Flash 2.0) worked for them, while another user later reported the same failure with an OpenRouter Gemini 2.0 Flash model.
      • A detailed community workaround suggested installing langchain-community and using:
      python
      from langchain_community.chat_models import ChatOpenAI
      
      llm = ChatOpenAI(
          model="google/gemini-2.0-pro-exp-02-05:free",
          openai_api_key=openrouter_api_key,
          openai_api_base="https://openrouter.ai/api/v1",
          temperature=0.0,
          max_tokens=4096,
          model_kwargs={"tool_choice": "auto"},
      )
      

      The same comment proposed patching convert_input_messages() in browser_use/agent/message_manager/utils.py and get_next_action() in the Agent class, but the thread never confirms that the patched code works.

      General advice: use an OpenRouter model that documents tool-use support, and keep the API key in an environment variable instead of hard-coding it in the script.

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What a GitHub user tried on GitHub (Didn't work)

      Reporter used ChatOpenAI from langchain_openai with base_url='https://openrouter.ai/api/v1 (opens external site)', model='deepseek/deepseek-chat', api_key='sk-or-v1-xxx', and use_vision=False. The browser opened but stayed empty; logs showed 'Could not parse response' then HTTP 429 'Authentication Fails. Multiple 401 errors detected'.

      Source: https://github.com/browser-use/browser-use/issues/567 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What @prigozhinfan tried on GitHub (Didn't work)

      Another user tried openai/chatgpt-4o-latest and deepseek/deepseek-r1 through OpenRouter and got HTTP 404 'No endpoints found that support tool use'. deepseek/deepseek-chat worked the day before but then started failing with 'Could not parse response'.

      Source: https://github.com/browser-use/browser-use/issues/567#issuecomment-2640555911 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What @kazGuido tried on GitHub (Worked)

      One commenter reported that disabling vision and using a different OpenRouter model (Gemini Flash 2.0) worked, while DeepSeek via OpenRouter did not.

      Source: https://github.com/browser-use/browser-use/issues/567#issuecomment-2663165027 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What @agn-7 tried on GitHub (Didn't work)

      Another user tested an OpenRouter Gemini 2.0 Flash model and got the same 'Could not parse response' style failure, so the earlier success was not reproduced.

      Source: https://github.com/browser-use/browser-use/issues/567#issuecomment-2693475773 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What @UnixSafe tried on GitHub (Outcome unclear)

      A commenter posted a detailed workaround: install langchain-community, use ChatOpenAI with openai_api_base='https://openrouter.ai/api/v1 (opens external site)' and model='google/gemini-2.0-pro-exp-02-05:free', and patch browser-use's message conversion. The thread does not confirm the final result, and the get_next_action() change is cut off.

      Source: https://github.com/browser-use/browser-use/issues/567#issuecomment-2710518976 (opens external site)

      Did this work for you?

    Add your answer or comment