Server Sent Events and Streaming APIs
Use the response-stream key to model streaming endpoints
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.
chat.yml
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.
chat.yml
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:
chat.yml