Typed bindings

Updated Aug 25, 2026View as Markdown

The worker protocol comes with machine-readable schemas. Point a code generator at them to get typed request and response types in your language.

You do not write the wire types yourself.

Files

Both files are in schemas/. They are generated from the engine's Rust types.

FileHolds
protocol.schema.jsonEvery wire type, in one JSON Schema. The top-level type is Protocol.
worker.openapi.jsonThe worker endpoint: POST /, from DecisionRequest to DecisionResponse.

Generate the types

Point a generator at protocol.schema.json. The examples keep the output as protocol.ts, protocol.go, or protocol.py.

TypeScript and Go, with quicktype:

npx quicktype --src-lang schema --lang typescript \
    --src schemas/protocol.schema.json --top-level Protocol \
    --just-types --prefer-unions -o protocol.ts

Go takes neither --just-types nor --prefer-unions:

npx quicktype --src-lang schema --lang go --package main \
    --src schemas/protocol.schema.json --top-level Protocol -o protocol.go

Python, with datamodel-code-generator:

datamodel-codegen \
    --input schemas/protocol.schema.json --input-file-type jsonschema \
    --output-model-type pydantic_v2.BaseModel --disable-timestamp --output protocol.py

For OpenAPI tools, generate from worker.openapi.json instead.

Next steps

  • Protocol: the types these schemas describe.
  • Workers: the code that uses them.