Skip to main content

OTTO Streaming — Server-Sent Events

Word-by-word intelligence streaming via SSE. First token delivered in under 50ms. Full structured intelligence card arrives in the final event.

1
F
u

SSE Protocol

Each SSE stream emits two event types:

# Chunk event — one or more words
data: {"chunk": "Revenue", "done": false}

# Final event — complete intelligence card
data: {"chunk": "", "done": true, "card": {
  "title": "Finance — Q1 2025 Performance",
  "platform": "FINANCE",
  "brain_score": 88,
  "narrative": "...",
  "recommended_actions": [...],
  "truth_verifier": {...}
}}

curl Example

curl "http://localhost:6670/api/otto/stream?query=what+is+our+cash+flow" -N

JavaScript / Browser

import { OTTOClient } from '@brainpredict/otto-sdk';

const otto = new OTTOClient({ baseUrl: 'http://your-otto-server:6670' });

await otto.streamAsk(
  'what is our Q1 profitability?',
  (chunk) => console.log(chunk),          // word-by-word
  (card)  => renderIntelligenceCard(card) // final card
);

React Hook Example

const [text, setText] = useState('');
const [card, setCard] = useState(null);

async function query(q) {
  setText('');
  setCard(null);
  await otto.streamAsk(q,
    chunk => setText(t => t + chunk + ' '),
    card  => setCard(card)
  );
}