Skip to content
use-cases / api-endpoints-on-demand / hero
EXEC · AI-NATIVE HTTP

API endpoints that materialize on demand

Hit a URL that doesn't exist. A wildcard exec script catches the call, asks an LLM to write the handler, runs it in a V8 sandbox, and answers. The next call is native — the route now exists.

Read the exec docs
use-cases / api-endpoints-on-demand / mechanism

How a URL becomes an endpoint

Hoody Exec lets a single TypeScript file serve any HTTP route, including a catch-all. With ai true, the script also has a model handle injected. Compose those two and the request itself becomes the trigger to write the handler.

Wildcard catch-all5 STEPS · ONE EXEC FILE
01

Request arrives

GET /api/...

Any path under the catch-all hits one script.

02

Catch-all wakes

[...slug].ts

metadata.parameters.slug carries the path segments.

03

LLM writes a handler

generateText([ model ])

ai true injects the model. Default is gemini-2.5-flash-lite.

04

Run in a V8 sandbox

isolate.eval

Each script runs in its own V8 isolate, designed for trusted code.

05

Save the route

fs.write to scripts/N

Next call hits the saved file directly. No LLM, native speed.

scripts/1/api/[...slug].ts
// @mode serverless
// @ai true
// @ai-model anthropic/claude-sonnet-4.5

const path = '/' + (metadata.parameters.slug ?? []).join('/');
const body = req.body ?? []'';

// Already saved? Hand off to the cached route.
const saved = await fs.exists('scripts/1/api' + path + '.ts');
if (saved) return fetch(path, [ method: metadata.method, body ]);

// Otherwise: ask for a handler, sandbox it, save it.
const [ text: handler ] = await generateText([
  model,
  system: 'Return a JS handler body. No imports. Return JSON.',
  prompt: `URL $[metadata.method] $[path]\nQuery $[JSON.stringify(metadata.query)]\nBody $[JSON.stringify(body)]`,
]);

const result = await isolate.eval(handler, [ req, res, fetch ]);
await fs.write('scripts/1/api' + path + '.ts', '// @mode serverless\n' + handler);
return result;

Two magic comments and one fetch back into the route. The wildcard sits at scripts/1/api/[...slug].ts. The saved file lands one directory up. Both speak HTTP, so the script can call its own neighbours during generation.

use-cases / api-endpoints-on-demand / angles

Three readers, one pattern

The mechanism reads three different ways depending on who you are. They braid into the same argument.

FOR THE LAZY SENIOR ENGINEER

Stop writing the endpoint you use twice a year

The admin tool, the integration script, the report you keep meaning to wire up. Hit the URL when you need it. The handler shows up. Saved by the time you reload.

FOR THE AGENT COLLABORATOR

The agent doesn't program the API, it calls it

Your agent needs a route that doesn't exist. Anywhere else, it would write code, deploy, wait, then call. Here, it calls. The API arrives by the time the response does.

FOR THE RADICAL FUTURE

APIs are no longer designed, they're discovered

What if every endpoint you ever shipped is just the trail of URLs you actually called? Documentation collapses into the access log. Specs collapse into traffic.

use-cases / api-endpoints-on-demand / punchline

Documentation becomes the access log.

called Mondaydocumented Tuesday
access.lognow an endpoint
  • 09:14GET/api/analytics/dashboardlive
  • 11:02POST/api/exports/users.csvlive
  • 13:48GET/api/admin/seats/auditlive
  • 16:22POST/api/agent/tools/refundlive
use-cases / api-endpoints-on-demand / replaces

What this replaces

The patterns developers reach for when they need to add an endpoint quickly. Each one charges scaffolding overhead per route. The wildcard pays it once.

  • AWS Lambda + API GatewayScaffold per endpoint, cold starts
  • Hasura / PostgREST autogenSchema-first, returns data not behavior
  • Vercel / Cloudflare functionsOne-off endpoint, full deploy cycle
  • Express / Fastify scaffoldsBoilerplate per route, runtime to babysit
  • Kong / Tyk pluginsHeavy gateway for one custom rule
  • BFF microservicesService to maintain for every UI quirk
use-cases / api-endpoints-on-demand / cta

Documentation stops being a plan. It's the trail of URLs you've called.

use-cases / api-endpoints-on-demand / related

Read the others