🔑 Get Your API Key

RAIS Cloud

RAIS Cloud is the hosted AI gateway built on top of the open RAIS Protocol. You need a RAIS API key to use it. Without a key, every request returns 401 Unauthorized.

⚠️

RAIS Cloud is in private beta. Keys are issued manually. Join the waitlist, and once approved you'll receive your key by email. → Join the waitlist (opens in a new tab)


Why you need a key

RAIS Cloud sits between your app and the AI providers (Groq, OpenAI, Anthropic, Gemini). It manages the provider API keys on its side — you never touch them.

Your app  →  RAIS Cloud (your ras_... key)  →  Groq / OpenAI / Anthropic

Without your ras_... key, RAIS Cloud has no way to:

  • Know which plan you're on (free vs pro)
  • Enforce your rate limits
  • Track your token usage
  • Bill you correctly

Every single request to /api/v1/chat or /api/v1/usage requires Authorization: Bearer ras_YOUR_KEY.


Step 1 — Get your key

Join the waitlist

Go to react-ai-stream-playground.vercel.app/cloud (opens in a new tab), scroll to the waitlist section, and enter your email.

You'll see: "You're #N on the list!" — that's confirmation.

Wait for approval

Access is granted manually during private beta. When approved, you'll receive an email with:

  • Your ras_test_... API key (free tier) or ras_live_... (paid tier)
  • Your monthly token limit
  • A link to your dashboard
💡

Free key format: ras_test_ followed by 40 hex characters
Paid key format: ras_live_ followed by 40 hex characters

Copy your key and keep it safe

The key is shown once in the email. Store it in your .env.local file immediately:

RAIS_API_KEY=ras_test_a1b2c3d4e5f6...

Never commit this file to git — it's already in .gitignore by default.


Step 2 — Check your dashboard

Once you have a key, go to the dashboard to verify it works:

react-ai-stream-gateway.vercel.app/dashboard (opens in a new tab)

  1. Paste your ras_... key in the input field
  2. Click Load — you'll see your plan, tokens used, and requests made
  3. Use the Test Chat tab to send a live message and confirm the stream works

If you see 401 Invalid key, double-check there are no extra spaces around the key.


Step 3 — Use the key in your app

With useAIChat (React hook — recommended)

This is the simplest integration. One change to your existing code:

app/page.tsx
'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: 'https://react-ai-stream-gateway.vercel.app/api/v1/chat',
    extraHeaders: {
      Authorization: `Bearer ${process.env.NEXT_PUBLIC_RAIS_API_KEY}`,
    },
  })
 
  return (
    <div style={{ height: '80vh' }}>
      <Chat messages={messages} onSend={sendMessage} onStop={stop} loading={loading} />
    </div>
  )
}

Add to .env.local:

NEXT_PUBLIC_RAIS_API_KEY=ras_test_your_key_here
⚠️

NEXT_PUBLIC_ exposes the key in the browser bundle. This is fine for a personal project or demo. For production, keep the key server-side — see the server-side pattern below.

With curl (quick test)

curl -N -X POST https://react-ai-stream-gateway.vercel.app/api/v1/chat \
  -H "Authorization: Bearer ras_test_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"messages":[{"role":"user","content":"Hello, what can you do?"}]}'

You should see RAIS v1 SSE frames streaming back:

data: {"type":"text","text":"Hello"}
data: {"type":"text","text":"! I can help you with..."}
data: {"type":"done"}

If you see data: {"type":"error","error":"invalid_key"} — check your key is correct and starts with ras_.

Server-side pattern (production)

Keep the key out of the browser by proxying through your own Next.js API route:

app/api/chat/route.ts
export const runtime = 'nodejs'
 
export async function POST(req: Request) {
  const body = await req.json()
 
  const upstream = await fetch(
    'https://react-ai-stream-gateway.vercel.app/api/v1/chat',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        // Key stays on the server — never reaches the browser
        Authorization: `Bearer ${process.env.RAIS_API_KEY}`,
      },
      body: JSON.stringify(body),
    }
  )
 
  return new Response(upstream.body, {
    headers: { 'Content-Type': 'text/event-stream', 'Cache-Control': 'no-cache' },
  })
}
app/page.tsx
// Now no key in the browser — just point to your own route
const { messages, sendMessage } = useAIChat({ endpoint: '/api/chat' })

API Reference

POST /api/v1/chat

Streams an AI response using the RAIS v1 protocol.

Required header:

Authorization: Bearer ras_YOUR_KEY

Request body:

{
  "messages": [
    { "role": "user", "content": "Hello" }
  ],
  "provider": "groq",
  "model": "llama-3.3-70b-versatile",
  "fallback": ["openai", "anthropic"]
}
FieldTypeDefaultDescription
messagesMessage[]requiredFull chat history
providerstring"groq"Primary provider to use
modelstringProvider defaultOverride the model
fallbackstring[]autoOrdered fallback if primary fails

Response: text/event-stream — RAIS v1 protocol

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

On error:

data: {"type":"error","error":"rate_limit","message":"Too many requests"}

GET /api/v1/usage

Returns token usage and request counts for your key.

Required header:

Authorization: Bearer ras_YOUR_KEY

Response:

{
  "key_id": "abc123",
  "plan": "free",
  "monthly_limit": 50000,
  "tokens_used": 12340,
  "requests": 89
}

GET /api/v1/health

Check if all providers are reachable. No authentication required.

curl https://react-ai-stream-gateway.vercel.app/api/v1/health
{
  "status": "ok",
  "providers": {
    "groq": { "ok": true, "latency_ms": 38 },
    "openai": { "ok": true, "latency_ms": 121 },
    "anthropic": { "ok": true, "latency_ms": 95 }
  },
  "timestamp": "2026-05-16T10:30:00.000Z"
}

Error codes

HTTPError codeMeaningFix
401missing_keyNo Authorization headerAdd Authorization: Bearer ras_...
401invalid_keyKey doesn't exist or was revokedCheck the key; get a new one from dashboard
429rate_limitToo many requests per minuteWait 60 seconds and retry
429token_capMonthly token limit reachedUpgrade plan at the playground
503provider_errorAll providers in the fallback chain failedCheck /api/v1/health; retry later

Available providers

ProviderIDDefault modelNotes
Groqgroqllama-3.3-70b-versatileDefault — lowest latency, fastest streaming
OpenAIopenaigpt-4o-miniGPT-4o, o1 series
Anthropicanthropicclaude-3-5-haiku-20241022Claude 3.5 Sonnet/Haiku
Geminigeminigemini-1.5-flashGemini 1.5 Pro, Flash

Automatic fallback: if groq is slow or returns an error, RAIS Cloud automatically falls back through the chain. You can override the chain:

{ "provider": "anthropic", "fallback": ["openai", "groq"] }

Pricing plans

PlanPriceMonthly tokensRate limit
Free€050,000 tokens20 req/min
Pro€10/mo500,000 tokens100 req/min
Team€49/mo5,000,000 tokens500 req/min
EnterpriseCustomUnlimitedCustom
💡

Free keys use the ras_test_ prefix. Paid keys use ras_live_. Your plan and limits are shown in the dashboard (opens in a new tab).

To upgrade: react-ai-stream-playground.vercel.app/cloud (opens in a new tab)


Choosing a provider

You don't need your own API keys for any provider — RAIS Cloud handles all of that.

Use caseRecommended provider
Lowest latency / fastest streaminggroq (default)
Long context / complex reasoninganthropic (Claude 3.5 Sonnet)
Widest model selectionopenai (GPT-4o series)
Cost-efficient at scalegroq or gemini

Full example — Next.js app

Everything needed to go from zero to a streaming AI chat in a new Next.js project:

npx create-next-app@latest my-chat --typescript --app
cd my-chat
npm install @react-ai-stream/react @react-ai-stream/ui
.env.local
RAIS_API_KEY=ras_test_your_key_here
app/api/chat/route.ts
export const runtime = 'nodejs'
 
export async function POST(req: Request) {
  const body = await req.json()
  const upstream = await fetch(
    'https://react-ai-stream-gateway.vercel.app/api/v1/chat',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        Authorization: `Bearer ${process.env.RAIS_API_KEY}`,
      },
      body: JSON.stringify(body),
    }
  )
  return new Response(upstream.body, {
    headers: { 'Content-Type': 'text/event-stream', 'Cache-Control': 'no-cache' },
  })
}
app/page.tsx
'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',
  })
  return (
    <div style={{ height: '100vh' }}>
      <Chat messages={messages} onSend={sendMessage} onStop={stop} loading={loading} />
    </div>
  )
}

Run it:

npm run dev

Open http://localhost:3000 — you have a fully streaming AI chat backed by Groq (with automatic fallback to OpenAI and Anthropic).


Open source commitment

RAIS Protocol, all SDK packages, compliance tools, DevTools, and the playground are MIT open source. RAIS Cloud is the optional hosted infrastructure layer — you can self-host the gateway or skip it entirely. The protocol is permanent and will never be closed.

Protocol spec → · Self-host the gateway → · GitHub → (opens in a new tab)