Code-as-Interface: How Two Tools Replace 2,500 Endpoints

The most radical pattern replaces tool definitions entirely with code generation. Instead of presenting the agent with a catalog of operations, you give it two capabilities: search (explore what’s available) and execute (act on what you found).

Cloudflare’s “Code Mode” is the clearest example: 2 tools replace 2,500 endpoint definitions. The agent writes JavaScript to search the OpenAPI spec, narrows to relevant endpoints, and chains multiple API calls in a single operation.

Token footprint: 1,170,000 → ~1,000. That’s a 99.9% reduction that stays fixed regardless of API size.

Anthropic and Block’s Goose agent independently converged on the same pattern. As Cloudflare’s engineers observed: “LLMs are better at writing code to call APIs than at calling APIs directly.”

This aligns the API with how the consumer actually thinks — through code, not through enumerated menus.

Read the full analysis on The Business Engineer

Read the full analysis on The Business Engineer

Scroll to Top

Discover more from FourWeekMBA

Subscribe now to keep reading and get access to the full archive.

Continue reading

FourWeekMBA