Server-sent events and streaming APIs
Server-sent events and streaming APIs
Use the response-stream key to model streaming endpoints
Server-sent events and streaming APIs
Use the response-stream key to model streaming endpoints
Fern Definition isn’t recommended for new customers and Fern isn’t accepting feature requests for this format. It remains supported for existing users.
This feature is available only for the Team 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.
If your API returns a series of JSON chunks as seen below
then simply specify the response under response-stream for your endpoint.
If your API returns server-sent-events, with the data and event keys as seen below
then make sure to include format: sse.
Stream parameterIt 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: