Skip to content

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

test(openrouter): assert request parameters are forwarded

MagMuelleredfccc40787a
diff --git a/tests/ci/models/test_llm_openrouter.py b/tests/ci/models/test_llm_openrouter.py
index 160321c16..333f9df98 100644
--- a/tests/ci/models/test_llm_openrouter.py
+++ b/tests/ci/models/test_llm_openrouter.py
@@ -28,7 +28,7 @@ def _completion(*, content: str | None = 'ok', choices: bool = True) -> ChatComp
)
-def test_request_params_are_not_client_params():
+async def test_request_params_reach_completion_not_client():
llm = ChatOpenRouter(model='openai/gpt-4o', api_key='test-key', top_p=0.9, seed=42)
client = llm.get_client()
@@ -37,6 +37,13 @@ def test_request_params_are_not_client_params():
assert 'top_p' not in llm._get_client_params()
assert 'seed' not in llm._get_client_params()
+ create = AsyncMock(return_value=_completion())
+ with patch.object(type(client.chat.completions), 'create', create):
+ await llm.ainvoke([UserMessage(content='question')])
+ request_kwargs = create.await_args_list[0].kwargs
+ assert request_kwargs['top_p'] == 0.9
+ assert request_kwargs['seed'] == 42
+
def test_provider_key_does_not_fall_back_to_openai_key(monkeypatch: pytest.MonkeyPatch):
monkeypatch.setenv('OPENAI_API_KEY', 'wrong-provider-key')