This Week in NET

Code Mode: Giving AI Agents an Entire API in 1,000 Tokens (With Demos)


Listen Later

In this episode of This Week in NET, host João Tomé is joined by Matt Curry to break down Code Mode: a way to give AI agents access to the entire Cloudflare API (2,500+ endpoints) using two tools and roughly ~1,000 tokens of context.  


Instead of exposing thousands of individual tools (which quickly becomes expensive and brittle), Code Mode lets the model write JavaScript to search and execute against a compact API context. The result is massive compression, lower cost, and better performance.


We also include demos showing how agents can query real infrastructure, navigate multiple accounts, and build things like multiplayer experiences using Durable Objects and WebSockets.


⏱️ Timestamps 

0:53 — Intro: agents, MCP, tokens, and what Code Mode means

2:53 — Why exposing 2,500+ endpoints as tools doesn’t scale

6:49 — How Code Mode works: generate an SDK and let the model write code

9:57 — Demo: querying deployed Workers and infrastructure

14:37 — Multiplayer with Durable Objects (live demo “wow” moment)

24:32 — Compression stats: 2 million tokens → ~1,000 tokens

27:26 — Code Mode SDK v2 and wrapping your own APIs

31:52 — The Sandbox: running untrusted code safely

38:03 — What’s next: progressive disclosure and MCP evolution


Mentioned blog posts:

  • Code Mode: give agents an entire API in 1,000 tokens

...more
View all episodesView all episodes
Download on the App Store

This Week in NETBy Cloudflare