The defaults
| Call | Deadline | Why |
|---|---|---|
| Most calls | 60 s | A reply that has not arrived by then is not coming. |
| models.turn() | 300 s | A turn can think for a long time before it answers. |
| assistant.generate() | none | Generation can take minutes; see below. |
| tools.convert(), tools.fetch() | none | Same reason. |
| Streaming calls | none | The connection is held open on purpose. |
The work does not stop because you stopped listening: it finishes, and the call is still billed. A client-side deadline would therefore cost you the call and return nothing. Bound it with an AbortSignal instead, which you control.
Setting your own
// For the whole client
const api = new IaGenify({ apiKey, timeout: 15_000 });
// For one call
await api.models.turn({ model, messages, signal: AbortSignal.timeout(30_000) });# For the whole client, in seconds
api = IaGenify(api_key=api_key, timeout=15)
# For one call
api.models.turn(model=model, messages=messages, timeout=30)Aborting
Every call takes a signal. An abort you asked for is passed through as-is — it is not rewrapped as a timeout — so you can tell your own cancellation apart from the client giving up.
const controller = new AbortController();
const running = agent.run({
message: "Audit the whole workspace.",
onEvent: console.log,
signal: controller.signal,
});
setTimeout(() => controller.abort(new Error("user cancelled")), 10_000);
try {
await running;
} catch (err) {
if (controller.signal.aborted) console.log("cancelled by us");
else if (err.code === "timeout") console.log("the client gave up");
}import threading
from iagenify import RequestTimeout
# Python has no AbortSignal: stop the agent from another thread
timer = threading.Timer(10, agent.stop)
timer.start()
try:
result = agent.run(message="Audit the whole workspace.", on_event=print)
if result["stopReason"] == "stopped":
print("cancelled by us")
except RequestTimeout:
print("the client gave up")
finally:
timer.cancel()The two failures you will see
| code | status | Meaning |
|---|---|---|
| timeout | 408 | No answer within the deadline. |
| unreachable | 503 | The request never got there: wrong baseUrl, no network, nothing listening. |
unreachable in a deployed service almost always means baseUrl is not the one you meant. Read api.baseUrl and compare it with https://api.iagenify.com.