← All work
Infrastructure · 2026

Edge API & Generated SDK/CLI Toolkit (Hono + OpenAPI on Workers)

An AI-cofounder / autonomous-startup-builder SaaS

Overview

The platform’s edge API service for an AI-cofounder / autonomous-startup-builder SaaS: a Hono + zod-openapi API running on Cloudflare Workers, with a curated TypeScript SDK and per-domain agent CLIs both generated from a single OpenAPI spec.

The Challenge

A fleet of autonomous agents needs a stable, typed contract to act through, wallets and credits, commerce, leads, threads, social platforms, ads, without each agent re-implementing transport, auth, or validation. The answer is a spec-first API whose SDK and CLIs are generated, so the contract stays the single source of truth across humans and agents.

What We Built

A Hono application on Workers exposing domain-segmented routes, ads, commerce, credits, leads, threads, social-platforms, suppliers, web, blog, stripe, plus webhook intake and async jobs. The OpenAPI spec is served at /openapi.json and drives code generation (@hey-api/openapi-ts) into a curated sdk/ and per-domain CLIs under cli/. State is held in Cloudflare D1; file uploads use R2 presigned URLs signed via aws4fetch. A credit/wallet ledger powers provider credit packs: GET /credits/packs is catalog-backed and fail-closed (503 until configured), and pack purchases spend the main wallet once and grant provider credits through the ledger, gated by an approval-secret header unless an explicit auto-purchase flag is set. Billing integrates Stripe directly.

Technologies & Approach

TypeScript on Bun for tooling, deployed to Cloudflare Workers. Hono with @hono/zod-openapi gives runtime validation and an authoritative spec in one place; codegen keeps the SDK and agent CLIs in lockstep so drift is impossible. Fail-closed defaults (configuration-gated catalogs, approval-secret guards, prices treated as configuration not constants) reflect a security-conscious money path.

Outcome / Impact

Provides the typed, edge-hosted contract the agent fleet and product app build against, with billing, credits and presigned storage handled centrally and the SDK/CLI surface kept automatically in sync with the spec.

Capabilities Demonstrated

  • Spec-first OpenAPI API on Cloudflare Workers (Hono + zod)
  • Single-source codegen to TypeScript SDK and per-domain agent CLIs
  • Credit/wallet ledger with fail-closed, approval-gated purchases
  • Stripe billing and R2 presigned upload flows
  • Domain-segmented routing across ads, commerce, leads, social and more
More work See all →