Set request timeouts
mainYou can prevent requests from hanging indefinitely using the timeout option.
CLI usage:
llm -m gemini-flash-latest 'prompt' -o timeout 1.5Python usage:
When using the llm library, pass the timeout parameter to model.prompt(). This raises an httpx.TimeoutException if exceeded.
import httpx, llm
model = llm.get_model("gemini/gemini-flash-latest")
try:
response = model.prompt("epic saga about mice", timeout=1.5)
print(response.text())
except httpx.TimeoutException:
print("Timeout exceeded")