Never Handcraft: Every Client Generated From One API

ForkTex Engineering · November 27, 2026 · 2 min

An API client is the code a website, an app, a script or another service uses to call a backend. Written by hand, it is a second copy of the API that nothing keeps in step with the first. We generate every client from one description of the API, and never edit what is generated.

The description is openapi.json, exported from the backend's own list of routes. One generation step turns it into a Python SDK, a TypeScript SDK and, for our web and mobile apps, typed hooks for every call.

The problem

A hand-written client passes review because it works today. It has no link to the route it calls, so when the backend renames a field, the client keeps compiling and starts failing in front of users. The bug is found by whoever meets it first.

One contract, many outputs

OutputGeneratedWritten by hand
Python SDKModels, and one method per routeThe client class: authentication, lifecycle, retries
TypeScript SDKsrc/generated/src/index.ts, which re-exports it
Web and mobile appsOne RTK Query slice per domain, with a typed hook per callCache tags and small enhancements, in separate files

Each output has two layers: a generated half that nobody edits, and a thin hand-written layer on top. Regenerating is safe because everything a person wrote lives in a file the generator never opens.

What a change looks like

A backend developer renames a field in a response. The API exports a new openapi.json, the clients are regenerated, and the TypeScript compiler points at every screen that still reads the old name. The mismatch becomes a build error on the developer's machine, before it reaches anyone else.

pnpm generate-api          # read openapi.json, regenerate the hooks
pnpm exec tsc --noEmit     # every stale use is now a type error

Agents use the same API

On our platforms, tools for AI agents follow the same rule from the other side. An MCP (Model Context Protocol) server is mounted over the same routes, so a new route is a new tool, with no second definition to maintain.

The weak point

The contract is only as current as its last export. If someone changes the backend and forgets to regenerate, the clients compile against an old copy. The fix is a check in the gate that regenerates and compares; not every one of our repositories has it yet.

Take it with you

Nothing here is ours alone. OpenAPI is an open standard, FastAPI exports it by itself, and generators exist for most languages. The rule is the part worth keeping: describe the API once, generate everything that calls it, and never edit what was generated.