ReqLLM - Composable LLM client built on Req

Yes - the easiest way is to pass an option to the generate_text or stream_text methods.

The provider base_url will be overridden for that request. api_key follows this pattern as well.

Here’s an example:

test "mocked chat happy path", %{base_url: base_url} do
  assert {:ok, response} =
           ReqLLM.generate_text("openai:gpt-4o-mini", "ping",
             base_url: base_url,
             api_key: "test"
           )

  assert ReqLLM.Response.text(response) == "pong"
end
1 Like