Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

fix(vercel): preserve provider error status

MagMuellere0737a614f5d
diff --git a/browser_use/llm/vercel/chat.py b/browser_use/llm/vercel/chat.py
index 1d1b4e3af..048364969 100644
--- a/browser_use/llm/vercel/chat.py
+++ b/browser_use/llm/vercel/chat.py
@@ -667,6 +667,9 @@ class ChatVercel(BaseChatModel):
stop_reason=response.choices[0].finish_reason if response.choices else None,
)
+ except ModelProviderError:
+ raise
+
except RateLimitError as e:
raise ModelRateLimitError(message=e.message, model=self.name) from e
diff --git a/tests/ci/models/test_llm_vercel.py b/tests/ci/models/test_llm_vercel.py
index 5a5af5faf..58f5c418f 100644
--- a/tests/ci/models/test_llm_vercel.py
+++ b/tests/ci/models/test_llm_vercel.py
@@ -6,7 +6,7 @@ from browser_use.llm.exceptions import ModelProviderError
from browser_use.llm.vercel.chat import ChatVercel
-def test_provider_key_does_not_fall_back_to_openai_key(monkeypatch: pytest.MonkeyPatch):
+async def test_provider_key_does_not_fall_back_to_openai_key(monkeypatch: pytest.MonkeyPatch):
monkeypatch.setenv('OPENAI_API_KEY', 'wrong-provider-key')
monkeypatch.setenv('AI_GATEWAY_API_KEY', 'gateway-key')
assert ChatVercel(model='openai/gpt-4o').get_client().api_key == 'gateway-key'
@@ -14,5 +14,5 @@ def test_provider_key_does_not_fall_back_to_openai_key(monkeypatch: pytest.Monke
monkeypatch.delenv('AI_GATEWAY_API_KEY')
monkeypatch.delenv('VERCEL_OIDC_TOKEN', raising=False)
with pytest.raises(ModelProviderError, match='Missing Vercel AI Gateway API key') as exc_info:
- ChatVercel(model='openai/gpt-4o').get_client()
+ await ChatVercel(model='openai/gpt-4o').ainvoke([])
assert exc_info.value.status_code == 401