TimeoutOptions#

Implement the model contract and normalize usage and stream output. See the guide.

class zett_agent.model.TimeoutOptions(connect=5.0, first_byte=60.0, idle=600.0)[源代码]#

How long a provider may stay silent before the request is given up on.

A model call has three stretches where nothing may arrive, and each gets its own limit, because the right wait is very different for each:

  • connect: opening the connection. A reachable host answers in milliseconds.

  • first byte: from sending the request until the response headers come back. Streaming APIs answer headers before the model has produced anything, so a long wait here means a gateway or proxy that took the request and did nothing.

  • idle: the longest gap between two chunks once the response has started. This can legitimately be minutes, because a reasoning model may think silently.

There is deliberately no limit on the total time of a response: a long answer that keeps streaming is healthy. A limit that is exceeded raises ProviderTimeoutError naming which stretch it was. A timeout is not retried, except for a failed connection, because a retry would wait the whole limit again and the first request may still be running (and billed) on the other side.

None disables a limit, which is how a provider behaved when none was set.

示例

Fail fast on a gateway that goes silent, and allow long silent reasoning:

OpenAIProvider("gpt-5", key, timeout=TimeoutOptions(first_byte=30, idle=900))
参数:
  • connect (float | None)

  • first_byte (float | None)

  • idle (float | None)

connect: float | None#

Seconds to open the connection.

first_byte: float | None#

Seconds from sending the request to receiving the response headers.

idle: float | None#

Seconds of silence tolerated between two chunks of a response that has started.