Server-Sent Events
Fern’s SDKs support Server-Sent Events (SSE) out of the box. This feature is especially relevant for chat completions, where you want to stream LLM outputs in real-time.
TypeScript
Python
When an endpoint is configured to use Server-Sent Events, the TypeScript SDK
method will return an AsyncIterable
of the underlying data type. This
allows you to use it in a for await
loop.
Below is an example method signature for a stream endpoint:
And here is an example of how a user would use the stream
method: