Skip to main content
This quickstart uses the free @withboundary/contract package. It does not require a Boundary account, API key, or hosted dashboard.
Using an AI coding assistant? Install the Boundary skill first so it can find the LLM output path, add the contract at the trust boundary, and verify accepted, repaired, and rejected outcomes.

Install the Boundary skill in your AI coding agent.

Open in Cursor

Install

Define what correct means

A contract is a schema plus rules. The schema checks the shape. Rules check the values your product cares about.
lead-contract.ts
debug: true turns on the built-in console logger. It prints attempts, failures, repairs, and the final result locally. No data leaves your process.

Wrap your model call

contract.accept() takes your existing LLM call as a function. Return the raw model output as a string. Boundary parses it, validates it, repairs failures when possible, and returns a typed result.
score-lead.ts
On the first attempt, attempt.repairs is empty. If the output fails, Boundary builds repair messages from the schema and rule violations. Your next model call receives those messages.

Handle the result

When result.ok is true, result.data is typed from your schema and every rule has passed. When result.ok is false, no data is returned. You decide whether to fail the request, retry with different context, or send it to a human review queue.

What local debugging shows

With debug: true, a failed first attempt gives you the important parts:
That is enough to tune rules, prompts, and reject handling before you wire the hosted dashboard.

Next steps

Local development

Use console logging, tests, and custom hooks without an API key

Add Boundary to an LLM feature

Adapt this pattern to your existing provider code

OpenAI guide

Use Boundary with OpenAI structured outputs

Production observability

Send contract events to the hosted dashboard