# Sync Tier WebSocket

> Progressive frame streaming

**Endpoint:** `wss://sync.render.weyl.ai/ws`

Stream generation frames progressively during inference.

## Connection Flow

```javascript
const ws = new WebSocket('wss://sync.render.weyl.ai/ws');

ws.onopen = () => {
  // 1. Authenticate
  ws.send(JSON.stringify({
    type: 'auth',
    token: API_KEY
  }));
  
  // 2. Submit generation
  ws.send(JSON.stringify({
    type: 'generate',
    modality: 'image',
    family: 'flux',
    model: 'dev',
    task: 't2i',
    format: '1024',
    prompt: 'cyberpunk street',
    stream_frames: true
  }));
};

ws.onmessage = (event) => {
  const msg = JSON.parse(event.data);
  
  if (msg.type === 'frame') {
    // Progressive frame (base64 JPEG)
    updatePreview(msg.data);
  }
  
  if (msg.type === 'complete') {
    // Final result (WebP URL)
    displayResult(msg.output);
  }
};
```

## Message Types

### `frame`
Progressive denoising frame (sent every 5 steps):

```json
{
  "type": "frame",
  "step": 15,
  "total_steps": 25,
  "data": "base64_jpeg_data..."
}
```

### `complete`
Final generation result:

```json
{
  "type": "complete",
  "output": "https://cdn.render.weyl.ai/i/xyz.webp",
  "latency_ms": 1847
}
```

## Frame Frequency

Frames are sent every 5 steps to balance bandwidth and smoothness.

**Example (25 steps):**
- Step 5, 10, 15, 20, 25 → 5 frames total