Skip to main content
Every SDK method accepts an optional options keyword argument that controls per-call timeouts and one-off headers. The same RequestOptions shape works for regular requests and for Server-Sent Events streams.

RequestOptions

RequestOptions is a TypedDict with two optional fields:

Override timeout per call

Use timeout to set a shorter or longer bound for a single request.
filename.py
The client-wide default is 30.0 seconds. See Client configuration for setting the default.

Inject one-off headers

Use headers to add request correlation IDs, feature flags, or override a default value once.
filename.py

Combining options

Pass both fields together when needed:
filename.py

Timeout and cancellation semantics

Python does not use AbortSignal. Cancellation is handled by httpx timeouts or by breaking out of a stream iteration.
  • When a request exceeds the configured timeout, the SDK raises FigraniumError with code="REQUEST_ABORTED". The __cause__ property carries the underlying httpx.TimeoutException.
  • When the request cannot reach the server (DNS failure, connection refused, TLS error), the SDK raises FigraniumError with code="NETWORK_ERROR". The __cause__ property carries the underlying httpx.HTTPError.
filename.py

Stream timeouts

Streams have no default timeout. Pass options={"timeout": 60.0} when you want a terminal deadline. The stream raises FigraniumError(code="REQUEST_ABORTED") when the timer fires.
filename.py
See Streaming for more on consuming SSE events.
Use timeout for hard deadlines on individual requests. For long-running streams, consider breaking out of the loop when your application state changes.
See Errors for the full error shape.