Streaming status
Stream queue updates over Server-Sent Events instead of polling.
Use the status stream for coding agents, CLIs, and dashboards that should show progress without manual polling.
Connect to the stream
const response = await fetch(
"https://audiolasso.dev/v1/queue/requests/req_01jabc/status/stream?logs=true",
{
headers: {
Authorization: `Bearer ${process.env.AUDIOLASSO_API_KEY}`,
Accept: "text/event-stream",
},
}
);
if (!response.body) throw new Error("No stream body");Parse events
const reader = response.body.getReader();
const decoder = new TextDecoder();
let buffer = "";
while (true) {
const { value, done } = await reader.read();
if (done) break;
buffer += decoder.decode(value, { stream: true });
const events = buffer.split("\n\n");
buffer = events.pop() || "";
for (const event of events) {
const data = event
.split("\n")
.find((line) => line.startsWith("data: "));
if (!data) continue;
const payload = JSON.parse(data.slice(6));
console.log(payload.status, payload.logs?.[0]?.message);
if (payload.status === "COMPLETED" || payload.status === "FAILED") {
reader.cancel();
break;
}
}
}Stream events
The status event payload matches the normal queue status response.
event: status
data: {"request_id":"req_01jabc","model":"audio/separate","status":"IN_PROGRESS"}