logo

DO it again: how we used Durable Objects to add WebSockets support and authentication to AI Gateway

ID: d86de8eb-3272-5791-873b-a34bf8f6f5e8

STIX ID: report--d86de8eb-3272-5791-873b-a34bf8f6f5e8

Feed Name: Cloudflare Blog

Date Published: 2024-11-19

Date Updated: 2026-04-27

Author: Catarina Pires Mota

...
...

Cloudflare announced a new WebSockets API for AI Gateway that provides a single, persistent, authenticated connection to AI providers, leveraging Durable Objects to handle scale, session-level settings, and concurrent streaming with request correlation via an eventId. The post details authentication options (API token via header or WebSocket subprotocol), message envelopes for non-streaming and streaming responses, and example client implementations for Node.js and browsers. The capability is in open beta now, with planned support for direct WebSocket-to-WebSocket connections to provider real-time APIs in Q1 2025.

Your team is not currently subscribed to this feed. You must subscribe to it in order to see this post.