• Platform
  • Solutions
  • Developers
  • Showcase
  • Pricing
  • Company
Get Started
  • Platform

    • Overview
    • Conductor
    • Architecture
    • Security
    • Status

    Capabilities

    • All 276
    • AI & ML
    • Storage
    • Auth & Identity
    • Billing
    • Search
    • Compute
    • Media

    SDK

    • SDK Overview
    • Face Modules
    • Quickstart
    • Playground
    • CLI
  • By Role

    • For Startups
    • For Enterprise
    • For Agencies
    • For Developers
    • For CTOs

    By Industry

    • Fintech
    • E-Commerce
    • Healthcare
    • Media
    • SaaS
    • Education

    By Use Case

    • AI Applications
    • Internal Tools
    • Marketplaces
    • Automation
  • Documentation

    • Getting Started
    • API Reference
    • Authentication
    • Webhooks
    • Templates
    • Sandbox

    Integrations

    • All Integrations
    • Stripe
    • OpenAI
    • AWS
    • GitHub
    • Build Your Own

    Resources

    • Technical Guides
    • Architecture Patterns
    • Project Templates
    • Glossary
    • Platform Changelog
    • SDK Changelog
  • Featured Demos

    • Showcase Gallery
    • SaaS Dashboard
    • AI Chat
    • E-Commerce Store
    • Admin Panel
    • Marketplace

    Case Studies

    • All Case Studies
    • Catalist — Fintech
    • Zumar — E-Commerce
    • Nova — AI SaaS
    • Meridian — Media
    • Atlas — Operations

    Enterprise

    • Enterprise Overview
    • Security
    • Compliance
    • SLA & Uptime
    • Deployment Options
    • Startup Program
  • Plans

    • Overview
    • Compare Plans
    • Pricing Calculator
    • Enterprise Pricing

    Compare

    • EEv3 vs Agencies
    • EEv3 vs No-Code
    • EEv3 vs Freelancers
    • EEv3 vs In-House
    • EEv3 vs Firebase

    Services

    • All Services
    • Custom Development
    • Platform Hosting
    • Consulting
    • AI Integration
  • About

    • About VertexStudio
    • Team
    • Culture
    • The Group
    • Partners
    • Testimonials

    Careers

    • Open Roles
    • Engineering

    More

    • Contact
    • Newsroom
    • Brand Assets
    • Trust Center
    • Legal
  • Get Started

Getting Started

  • Introduction
  • Getting Started
  • Templates

API

  • API Reference
  • Face API
  • Authentication
  • Webhooks
  • Error Handling
  • Rate Limits
  • Streaming
  • Batch Operations

Tools

  • Sandbox

Migration

  • Migration Guide
  • From Firebase
  • From Supabase

Changelog

  • SDK Changelog

Getting Started

  • Introduction
  • Getting Started
  • Templates

API

  • API Reference
  • Face API
  • Authentication
  • Webhooks
  • Error Handling
  • Rate Limits
  • Streaming
  • Batch Operations

Tools

  • Sandbox

Migration

  • Migration Guide
  • From Firebase
  • From Supabase

Changelog

  • SDK Changelog

Streaming

Server-sent events and streaming responses

Use streaming for AI responses, real-time data, and large payloads. The EEv3 API uses Server-Sent Events (SSE) to deliver incremental results as they become available.

When to Use Streaming

  • AI responses— show tokens as they generate for better perceived performance
  • Real-time data— live dashboards, log tailing, and event feeds
  • Large payloads— process data incrementally without buffering everything in memory

SDK Streaming

Pass stream: true to any face method that supports it. The SDK returns an async iterable you can consume with for await...of.

stream.ts
const stream = await ee.ai.generate({
  model: 'claude-sonnet-4-20250514',
  prompt: 'Write a short story about a robot',
  stream: true,
})

for await (const chunk of stream) {
  process.stdout.write(chunk.text)
}

// Final result available after stream ends
console.log('\nTokens used:', stream.usage.total)

SSE Format

The raw SSE stream uses standard text/event-stream format with named events for chunks, completion, and errors.

event-stream
event: chunk
data: {"text":"Once","index":0}

event: chunk
data: {"text":" upon","index":1}

event: chunk
data: {"text":" a","index":2}

event: chunk
data: {"text":" time","index":3}

event: done
data: {"usage":{"input":12,"output":487},"requestId":"req_abc123"}

Client-Side: EventSource API

In the browser, use the native EventSource API to consume the stream.

client.ts
const source = new EventSource('/api/stream?prompt=Hello')

source.addEventListener('chunk', (event) => {
  const data = JSON.parse(event.data)
  document.getElementById('output').textContent += data.text
})

source.addEventListener('done', (event) => {
  const data = JSON.parse(event.data)
  console.log('Stream complete:', data.requestId)
  source.close()
})

source.addEventListener('error', () => {
  console.error('Stream error')
  source.close()
})

Server-Side: Next.js Route Handler

Proxy the stream through your own API route to keep your API key server-side. The SDK provides a toReadableStream() helper.

app/api/stream/route.ts
import { createClient } from '@evileye/sdk'

const ee = createClient({
  token: process.env.EE_TOKEN!,
  entity: 'my-company',
})

export async function POST(req: Request) {
  const { prompt } = await req.json()

  const stream = await ee.ai.generate({
    model: 'claude-sonnet-4-20250514',
    prompt,
    stream: true,
  })

  return new Response(stream.toReadableStream(), {
    headers: {
      'Content-Type': 'text/event-stream',
      'Cache-Control': 'no-cache',
      Connection: 'keep-alive',
    },
  })
}

Error Handling During Streams

Errors during a stream are delivered as an error event in the SSE stream and thrown as exceptions in the SDK iterator.

error-handling.ts
const stream = await ee.ai.generate({
  prompt: 'Hello',
  stream: true,
})

try {
  for await (const chunk of stream) {
    process.stdout.write(chunk.text)
  }
} catch (err) {
  // Stream errors are thrown during iteration
  if (err.code === 'STREAM_INTERRUPTED') {
    console.error('Stream was interrupted:', err.message)
    // Optionally restart from last known position
  }
}

Related

  • API Reference— which faces and methods support streaming
  • Error Handling— error codes and recovery strategies
VertexStudio

The platform behind every company. 276 capabilities through one API.

Platform

  • Overview
  • Conductor
  • Capabilities
  • Architecture
  • Security
  • Status
  • Changelog

SDK & Docs

  • SDK
  • Face Modules
  • Quickstart
  • API Reference
  • Documentation
  • Integrations

Solutions

  • For Startups
  • For Enterprise
  • For Agencies
  • For Developers
  • Showcase
  • Case Studies

Services

  • Custom Development
  • Platform Hosting
  • API Access
  • Consulting
  • AI Integration

Company

  • About
  • Team
  • Careers
  • Partners
  • Newsroom
  • Contact

Legal

  • Privacy Policy
  • Terms of Service
  • DPA
  • Acceptable Use
  • Trust Center
© 2026 VertexStudio. All rights reserved.
Privacy·Terms·Trust Center
Built with EEv3