react-ai-streamv1.0.0
DocsnpmGitHubView source ↗
RAIS Protocol v1 · Production

Universal AI streaming
infrastructure.

One wire protocol. Any server. Any client framework.

Works with Anthropic, OpenAI, Groq, or any streaming endpoint.

$npm install @react-ai-stream/react @react-ai-stream/uicopy
Quickstart →
RAIS wire format
data: {"type":"text","text":"Hello"}
data: {"type":"text","text":", world"}
data: {"type":"done"}

Three models, one prompt

Llama 70B · Llama 8B · Llama 4 Scout — same question, three answers, powered by your RAIS key
POST /api/chat → text/event-stream● LIVE
Llama 3.3 · 70BGroq · balanced
Waiting for a message…
Llama 4 ScoutGroq · newest
Waiting for a message…
Compound BetaGroq · agentic
Waiting for a message…

What you get

useAIChat hook

Messages, loading, error, stop — all managed. Zero boilerplate.

🌐Any backend

Anthropic, OpenAI, Groq, FastAPI, Express — same hook, any server.

💚Vue 3 support

Same useAIChat API surface as a Vue 3 composable.

Event hooks

onToken, onComplete, onError for side-effects and analytics.

🎨Drop-in UI

<Chat /> with Markdown + syntax highlighting, or bring your own.

Full TypeScript

Strict types, ESM + CJS, 117 passing tests across 8 packages.

As simple as this

import { useAIChat } from '@react-ai-stream/react'
import { Chat } from '@react-ai-stream/ui'
import '@react-ai-stream/ui/styles'

export default function Page() {
  const {
    messages, sendMessage,
    loading, stop,
  } = useAIChat({
    endpoint: '/api/chat',
    // OpenAI → Anthropic → Groq?
    // Just change the route. Not the hook.
  })

  return (
    <Chat
      messages={messages}
      onSend={sendMessage}
      onStop={stop}
      loading={loading}
    />
  )
}

The RAIS ecosystem

@react-ai-stream/react
useAIChat hook + AIChatProvider
~8 kB
@react-ai-stream/ui
<Chat>, <MessageList>, <MarkdownRenderer>
~12 kB
@react-ai-stream/vue
Vue 3 composable — same API
~9 kB
@react-ai-stream/express
raisMiddleware() for Express
~4 kB
rais (Python)
stream_response() for FastAPI
pure py
Full docs →GitHub ↗
RAIS Protocol v1

Three event types.
That's the entire spec.

Any server in any language that emits text, done, and error events over SSE is automatically compatible with every RAIS client.

data: {"type":"text","text":"…"}
data: {"type":"done"}
data: {"type":"error","error":"…"}
npx rais-compliance http://localhost:3000/api/chat