logo

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

ID: 0a243927-f3b5-5470-9979-4c6d1f6928a0

STIX ID: report--0a243927-f3b5-5470-9979-4c6d1f6928a0

Feed Name: Cloudflare Blog

Date Published: 2024-11-19

Date Updated: 2026-04-27

Author: Catarina Pires Mota

...
...

Cloudflare announces a beta WebSockets API for AI Gateway that provides a single, persistent, authenticated connection to supported AI providers via Durable Objects, reducing connection overhead and simplifying scale. The API supports authentication with `cf-aig-authorization` (and `sec-websocket-protocol` for browsers), reuses Universal Endpoint logic, and introduces `eventId` to correlate concurrent streaming responses. The post includes example code for Node.js and browsers, explains metadata wrapping for responses, and outlines planned support for WebSocket-to-WebSocket provider connections in Q1 2025.

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