Real-time endpoints & WebSockets
For applications deployed on fal runtime; in addition to regular HTTP endpoints, developers might choose to implement auxiliary interfaces on top of raw WebSockets or fal’s (stateless) real-time application framework.
Under a fal.App
, for any endpoint that deal with real-time connectivity, @fal.realtime()
decorator
can be used instead of @fal.endpoint
to automatically make the interface compatible with fal’s real-time clients. The
functions do not provide any session state, and are meant to be used for reducing the overall latency (with fal’s binary protocol)
and eliminating fixed connection establishing overheads.
For power users who want to build stateful applications with their own real-time protocol, a @fal.endpoint
can
be initialized with is_websocket=True
flag and the underlying function will receive the raw WebSocket connection and
can choose to use it however it wants.