Home / Companies / Cloudflare / Blog / Post Details
Content Deep Dive

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

Blog post from Cloudflare

Post Details
Company
Date Published
Author
Catarina Pires Mota, Gabriel Massadas
Word Count
1,433
Company Posts That Month
8
Language
English
Hacker News Points
-
Post removed?
No
Summary

We've introduced a WebSockets API that establishes a single, persistent connection to the AI Gateway, enabling continuous communication and reducing the overhead of repeated handshakes and TLS negotiations. This API allows developers to access all AI providers supported by AI Gateway via WebSocket, with the option to authenticate requests using Cloudflare API tokens or custom headers in browser WebSocket clients. The new API uses Durable Objects to handle all messages for the connection, storing and applying AI Gateway settings passed via headers on a per-request basis. We've also introduced authentication for the AI Gateway WebSockets API, requiring a valid token included in the cf-aig-authorization header. This allows developers to maintain a single TCP connection between their client or server application and the AI Gateway, while ensuring security and scalability. The new API is now in beta and open to everyone, with support for streaming requests and handling asynchronous events through an eventId field.

Trends Found in this Post
Trend Post Mentions Total Month Mentions Posts Companies MoM
Real-time 11 3,107 740 193 -25%
Use This Data

Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.