Real-world examples of using Durablr to handle Server-Sent Events streams without serverless timeouts
# Durablr API is hosted at:
https://www.durablr.run
The API is available at https://www.durablr.run
Stream OpenAI chat completions through webhooks to avoid serverless timeouts:
curl -X POST https://www.durablr.run/stream/subscribe \
-H "Content-Type: application/json" \
-d '{
"method": "POST",
"streamUrl": "https://api.openai.com/v1/chat/completions",
"webhookUrl": "https://webhook.site/your-unique-url",
"headers": {
"Authorization": "Bearer YOUR_OPENAI_API_KEY",
"Content-Type": "application/json"
},
"body": {
"model": "gpt-4",
"messages": [{"role": "user", "content": "Write a creative story about space exploration"}],
"stream": true,
"max_tokens": 500
}
}'
{"streamId": "7f8c9d2e-4b5a-1c3d-9e8f-2a1b3c4d5e6f"}
Subscribe to any Server-Sent Events endpoint:
curl -X POST https://www.durablr.run/stream/subscribe \
-H "Content-Type: application/json" \
-d '{
"streamUrl": "https://your-sse-endpoint.com/events",
"webhookUrl": "https://webhook.site/your-unique-url",
"headers": {
"Authorization": "Bearer YOUR_TOKEN"
}
}'
your-unique-url
in the examples aboveDurablr forwards streaming chunks in real-time:
{
"streamId": "7f8c9d2e-4b5a-1c3d-9e8f-2a1b3c4d5e6f",
"type": "chunk",
"data": "data: {\"id\":\"chatcmpl-ABC123\",\"object\":\"chat.completion.chunk\",\"created\":1756648138,\"model\":\"gpt-4-0613\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" couldn\"},\"logprobs\":null,\"finish_reason\":null}]}\n\n",
"timestamp": "2025-08-31T13:49:05.649Z"
}
{
"streamId": "7f8c9d2e-4b5a-1c3d-9e8f-2a1b3c4d5e6f",
"type": "completed",
"timestamp": "2025-08-31T13:49:15.123Z"
}
data:
lines to extract the actual JSON responsescurl https://www.durablr.run/stream/active
{"activeStreams": ["7f8c9d2e-4b5a-1c3d-9e8f-2a1b3c4d5e6f"], "count": 1}
curl -X DELETE https://www.durablr.run/stream/subscribe/7f8c9d2e-4b5a-1c3d-9e8f-2a1b3c4d5e6f
{"message": "Stream stopped", "streamId": "7f8c9d2e-4b5a-1c3d-9e8f-2a1b3c4d5e6f"}
Handle long AI responses without timeouts
Real-time analytics and metrics feeds
Long-running data transformation jobs
Real-time financial data streams
Device telemetry and sensor data
Streaming chat and messaging systems