This Post request takes some time, and fails in Req with a mint timeout error, but works fine with Httpoison. How can I configure the timeout with Req?
body =
%{
prompt: prompt,
model: "claude-2",
max_tokens_to_sample: 5000,
stream: false
}
|> Jason.encode!()
{:ok, %HTTPoison.Response{status_code: 200, body: body}} =
HTTPoison.post(
"https://api.anthropic.com/v1/complete",
body,
headers,
recv_timeout: 120_000
)
completion =
body
|> Jason.decode!()
|> Map.get("completion")
With Req this fails and times out:
{:ok, %Req.Response{body: %{"completion" => completion}}} =
Req.post("https://api.anthropic.com/v1/complete",
json: %{
prompt: prompt,
model: "claude-2",
max_tokens_to_sample: 5000,
stream: false
},
headers: headers,
connect_options: [timeout: 120_000]
)
Appreciate the help!