Skip to content

Instantly share code, notes, and snippets.

View ayan4m1's full-sized avatar

Andrew DeLisa ayan4m1

View GitHub Profile
@nicolay-r
nicolay-r / streaming-llm-replicate-api.js
Last active February 17, 2025 14:44
No-string streaming mode for Replicate LLM models in Javascript
// This is a customized version of the original script:
// https://til.simonwillison.net/llms/streaming-llm-apis
// Adapted for Replicate Streaming API documentation:
// https://replicate.com/docs/topics/predictions/streaming
async function* sseStreamIterator(apiUrl, requestBody, extraHeaders) {
// POST.
let response = await fetch(apiUrl, {
method: 'POST',