Defining a contract
defineContract returns a DefinedContract<T> — a reusable object you call .accept() on whenever you want to run an LLM call through this contract.
Using a contract
The.accept() method takes your LLM call as a function. You own the LLM call. Boundary owns the validation.
attempt object gives you everything you need:
The RunFn
Your function must match this signature:
null if the LLM returned nothing.
The
RunFn must return a string, not a parsed object. Extract the text content from your provider’s response object before returning.Your existing Zod schemas work
Boundary uses Zod for schema validation. If you already have Zod schemas in your codebase, pass them directly — no migration, no rewrite, no Boundary-specific DSL.Configuration options
defineContract accepts these options:
Next steps
Rules
Write domain correctness rules
The Repair Loop
How Boundary turns failures into fixes