Server-sent events and streaming APIs
Use the response-stream key to model streaming endpoints
Pro and Enterprise feature
This feature is available only for the Pro and Enterprise plans. To get started, reach out to support@buildwithfern.com.
Specifying response-stream on an endpoints allows you to represent endpoint responses that are streaming.
JSON streaming
If your API returns a series of JSON chunks as seen below
then simply specify the response under response-stream for your endpoint.
Server-sent events
If your API returns server-sent-events, with the data and event keys as seen below
then make sure to include format: sse.
Stream parameter
It has become common practice for endpoints to have a stream parameter that
controls whether the response is streamed or not. Fern supports this pattern in a first
class way.
Simply specify the stream-condition as well as the ordinary response and the streaming response: