Introduction

Universal AI streaming infrastructure

One wire protocol. Any server. Any client framework.

The RAIS Protocol (React AI Stream) is a minimal three-event SSE standard for streaming AI responses from any backend to any frontend. This monorepo ships everything you need: a React hook, Vue composable, Express middleware, Python helper, DevTools panel, and a scaffolding CLI.

React💚 Vue 3🚂 Express🐍 Python / FastAPI🔍 DevTools Compliance CLI🚀 Scaffolding CLI
npm install @react-ai-stream/react

Want to skip managing AI provider accounts? RAIS Cloud handles Groq, OpenAI, Anthropic, and Gemini on its side. You only need one ras_... key — no Groq account, no OpenAI billing, nothing. Get your RAIS API key →


Try it live — right here

No API key. No install. Streaming starts instantly.

Full playground with protocol inspector →


30 seconds to a streaming chat

npx create-ai-stream-app

Or install manually:

'use client'
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, FastAPI — any streaming endpoint
  })
  return <Chat messages={messages} onSend={sendMessage} onStop={stop} loading={loading} />
}

The hook returns plain data. Drop <Chat /> in for zero-config, or wire messages to any UI. Full quickstart →


All packages — click to explore


Who is this for?

AI copilot builders
  • Sidebar assistant in a SaaS product
  • Floating chat widget
  • Inline doc helper
Multi-model comparison
  • Run 3 providers in parallel
  • Side-by-side response quality
  • Cost/speed tradeoffs
SaaS dashboards
  • Already have a design system
  • Don't want locked-in UI
  • Need isolated chat instances
Non-Node backends
  • Python / FastAPI
  • Go / Rails
  • Any server that speaks HTTP+SSE
Internal tooling
  • Employee Q&A bots
  • Knowledge base search
  • Report generation
Customer support chat
  • Swap models without frontend deploys
  • Route by region or topic
  • Stream long answers

Why backend-agnostic matters

Most AI chat libraries are secretly backend libraries. They stream from OpenAI directly, or through their own cloud, or via a specific server adapter. The React hook is just a thin client on top of one particular provider.

react-ai-stream takes a different approach: the hook speaks a simple HTTP streaming protocol. Any server that produces that protocol works.

data: {"type":"text","text":"Hello"}
data: {"type":"text","text":", world"}
data: {"type":"done"}

Three event types. That's the entire contract between your server and your React component. This means:

  • Switch providers without touching React. OpenAI → Anthropic → your own model? Change the API route, not the frontend.
  • No API keys in the browser. The hook talks to your server, which talks to the LLM.
  • Multiple providers simultaneously. Run useAIChat three times with three endpoints — each instance is fully isolated.
  • Any backend language. FastAPI, Go, Rails, Cloudflare Workers — if it can stream SSE, it works.

Deep dive: Why backend-agnostic? →


What you get

react-ai-streamVercel AI SDK
Bundle size~20 kB total~90 kB+
Framework requirementNone — plain ReactNext.js optimized
Multiple isolated chat instancesPer hook, zero configShared context
Bring your own UIFirst-classNo
Event hooks (onToken, onComplete)Limited
Backend languageAny (HTTP+SSE)Node.js preferred
Vue supportNo

Both are MIT and well-maintained. Choose react-ai-stream when you want portable streaming primitives with no framework opinions. Choose Vercel AI SDK when you need tight Next.js RSC integration.


The RAIS wire protocol

Any server in any language that emits these three event types works with any RAIS client:

Content-Type: text/event-stream

data: {"type":"text","text":"Hello"}

data: {"type":"text","text":" world"}

data: {"type":"done"}

That's the entire protocol. Verify any server with:

npx rais-compliance http://localhost:3000/api/chat

Full protocol spec → · Compliance checker →


Next steps