Skip to content
Agent Stack
  • AI SDK
  • AI Gateway
  • Sandbox
  • Passport
  • Connect
  • eve
Core Platform
  • Security
  • Content Delivery
  • Fluid Compute
  • Observability
  • Workflows
  • CI/CD
Tools
  • Next.js
  • Vercel Agent
  • Vercel Plugin
  • Open Source
  • Domains↗
  • v0↗
Learn
  • Docs
  • About
  • Blog
  • Changelog
  • Knowledge Base
Build
  • AI Apps
  • Web Apps
  • Marketing Sites
  • Platforms
  • Commerce
Explore
  • Customers
  • Marketplace
  • Partner Finder
  • AWS
  • Community↗
EnterprisePricing
Contact
Log InSign Up
Dashboard

Products

Agent Stack

  • AI SDK
  • AI Gateway
  • Sandbox
  • Passport
  • Connect
  • eve

Core Platform

  • Security
  • Content Delivery
  • Fluid Compute
  • Observability
  • Workflows
  • CI/CD

Tools

  • Next.js
  • Vercel Agent
  • Vercel Plugin
  • Open Source
  • Domains↗
  • v0↗
Resources

Learn

  • Docs
  • About
  • Blog
  • Changelog
  • Knowledge Base

Build

  • AI Apps
  • Web Apps
  • Marketing Sites
  • Platforms
  • Commerce

Explore

  • Customers
  • Marketplace
  • Partner Finder
  • AWS
  • Community↗
Enterprise
Pricing
Sign UpLog In
Contact

FastAPI AI Chat with WebSocket

A real-time AI chat application using Next.js, FastAPI, WebSocket, and the Python AI SDK.

DeployView Demo

FastAPI AI Chat with WebSocket

A real-time AI chat application using Next.js (frontend), FastAPI (backend), WebSocket for streaming, and the Python AI SDK for LLM integration. Deployed on Vercel using Services.

Demo

https://fastapi-ai-chat.vercel.app/

How It Works

  • The frontend is a Next.js single-page app with a chat UI that connects to the backend via WebSocket.
  • The backend is a FastAPI server that accepts WebSocket connections, streams LLM responses using the Python AI SDK, and sends text deltas back to the client in real time.
  • On Vercel, the frontend and backend run as separate services routed by path prefix (/ and /api).

How to Use

Local Development

# Clone
npx giget@latest gh:vercel/examples/websockets/fastapi-ai-chat fastapi-ai-chat
cd fastapi-ai-chat
# Set your AI Gateway API key
echo "AI_GATEWAY_API_KEY=your-key-here" > .env
# Run both services
vercel dev

Open http://localhost:3000.

Environment Variables

VariableDescription
AI_GATEWAY_API_KEYVercel AI Gateway API key (required)
AI_MODELModel to use
(default: anthropic/claude-sonnet-4-6)

Learn More

  • Vercel Services - learn how services work on Vercel.
  • AI Gateway - learn about AI Gateway.
GitHub
Ownervercel
Repositoryexamples
LicenseView License
Use Cases
Starter
AI
Stack
Next.js
FastAPI

Related Templates

eve Personal Agent

Fork your own personal agent. One identity across web, Slack, and iMessage, with memory you can import, edit, and approve.
eve Personal Agent thumbnail

eve Incident Response Agent

sre investigates production issues using a hypothesis-driven approach and outputs verifiable evidence from connected sources.
eve Incident Response Agent thumbnail

eve Typefully Agent

Run your social presence from Slack. Drafts for X, LinkedIn, and more via Typefully, schedules on approval, reports analytics weekly.
eve Typefully Agent thumbnail

Agent Stack

  • AI SDK
  • AI Gateway
  • Sandbox
  • Workflows
  • ConnectNew
  • PassportNew
  • eveNew

Core Platform

  • CI/CD
  • Content Delivery
  • Fluid Compute
  • Observability

Security

  • Platform Security
  • WAF
  • Bot Management
  • BotID

Tools

  • Vercel DropNew
  • Vercel Agent
  • Vercel PluginNew
  • Agent Skills
  • Domains
  • v0

Frameworks

  • eveNew
  • Next.js
  • Nuxt
  • SvelteKit
  • Nitro
  • Turborepo
  • Tanstack Start
  • FastAPI
  • xmcp
  • All frameworks

SDKs

  • Vercel SDK
  • Workflow SDKNew
  • Flags SDK
  • Chat SDKNew
  • Queues SDKNew
  • Streamdown

Build

  • AI Apps
  • Web Apps
  • Marketing Sites
  • Platforms
  • Commerce
  • Platform Engineers
  • Design Engineers

Learn

  • Docs
  • Blog
  • Changelog
  • Knowledge Base
  • Academy
  • Articles
  • Community
  • Is Agentic

Explore

  • Customers
  • Marketplace
  • Templates
  • Partner Finder
  • Vercel + AWS

Company

  • About
  • Careers
  • Press
  • Events
  • Startups
  • Shipped on Vercel
  • Open Source Program
  • Enterprise
  • Pricing
  • Help

Legal & Trust

  • Privacy Policy
  • Terms of Service
  • Cookie Policy
  • DPA
  • Acceptable Use Policy
  • Legal (all documents)
  • Trust Center
  • Status

Social

  • GitHub
  • X
  • LinkedIn
  • YouTube
  • Instagram
  • VercelVercel
DeployView Demo

Loading status…

Select a display theme: