# WebSocket support is now available for Python Functions

**Published:** July 23, 2026 | **Authors:** Fantix King, Greg Schofield, Ricardo Gonzalez | **Contributors:** Eric Dodds

---

Vercel now supports WebSocket connections for Python applications.

WebSockets enable bidirectional communication between client- and server-side code, powering real-time features like interactive AI streaming, real-time chat, and multiplayer live collaboration. Both ASGI and WSGI applications are supported, including frameworks like FastAPI, Django, and Flask.

**app.py**
```python
import fastapi

app = fastapi.FastAPI()


@app.websocket("/api/ws")
async def websocket_endpoint(websocket: fastapi.WebSocket):
    await websocket.accept()
    try:
        while True:
            message = await websocket.receive_text()
            await websocket.send_text(message)
    except fastapi.WebSocketDisconnect:
        pass
```

Explore the [FastAPI AI Chat](https://github.com/vercel/examples/tree/main/websockets/fastapi-ai-chat) and [Flask AI Chat](https://github.com/vercel/examples/tree/main/websockets/flask-ai-chat) examples, or [read the WebSockets documentation](https://vercel.com/docs/functions/websockets#python-frameworks) to get started.

---

📚 **More updates:** [View all changelog entries](/changelog/sitemap.md) | [Blog](/blog/sitemap.md)