Skip to content

How to Use Streaming

Get real-time progress updates during content generation.

Overview

Streaming allows you to receive incremental updates as a prediction progresses, rather than waiting for the final result. This is useful for showing progress indicators or partial results to your users.

Enabling Streaming

Add stream: true to your request:

bash
curl -X POST "https://api.get3w.com/api/v3/get3w/flux-dev" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A cat in space",
    "stream": true
  }'

Server-Sent Events (SSE)

When streaming is enabled, the response uses Server-Sent Events format:

data: {"status": "processing", "progress": 0.1}

data: {"status": "processing", "progress": 0.5}

data: {"status": "processing", "progress": 0.9}

data: {"status": "completed", "outputs": ["https://cdn.get3w.com/outputs/image-xxx.png"]}

Client Examples

Python

python
import requests

response = requests.post(
    "https://api.get3w.com/api/v3/get3w/flux-dev",
    headers={
        "Authorization": "Bearer YOUR_API_KEY",
        "Content-Type": "application/json"
    },
    json={
        "prompt": "A cat in space",
        "stream": True
    },
    stream=True
)

for line in response.iter_lines():
    if line:
        data = line.decode("utf-8")
        if data.startswith("data: "):
            print(data[6:])

JavaScript

javascript
const response = await fetch("https://api.get3w.com/api/v3/get3w/flux-dev", {
    method: "POST",
    headers: {
        "Authorization": "Bearer YOUR_API_KEY",
        "Content-Type": "application/json"
    },
    body: JSON.stringify({
        prompt: "A cat in space",
        stream: true
    })
});

const reader = response.body.getReader();
const decoder = new TextDecoder();

while (true) {
    const { done, value } = await reader.read();
    if (done) break;
    console.log(decoder.decode(value));
}

Supported Models

Not all models support streaming. Check the model's documentation for streaming availability.

Next Steps

Released under the MIT License.