API reference for the Layercode Node.js Backend SDK.
streamResponse
function is the main entry point for the SDK. It takes the request body (from the Layercode webhook request) and a handler function as arguments. The handler function receives a stream
object that can be used to send SSE events to the client.
requestBody
: The request body from the client. See Webhook Request Payload.handler
: An async function that receives a stream
object.stream.tts(content: string)
: Sends a text to be spoken to the user (tts stands for text-to-speech).stream.data(content: any)
: Sends any arbitrary data to the frontend client. Use this for updating your frontend UI.stream.end()
: Closes the stream. Must be called at the end of your response.