Install
Basic usage
TypeBox types produce JSON Schema directly. Pass them to the Vercel AI SDK’sjsonSchema() wrapper to use with dottxt:
Adding constraints
TypeBox methods map directly to JSON Schema keywords:Optional and nullable fields
Type.Optional() removes the field from required. Type.Union([Type.String(), Type.Null()]) allows null.
Arrays
Nested objects
Type mapping
Notes
- Pass
{ additionalProperties: false }as the second argument toType.Object()when you want strict object schemas. TypeBox does not set this by default, so omit it only when you intentionally want an open object. - TypeBox types are plain objects, so
JSON.stringify(Contact)gives you the JSON Schema directly. Static<typeof Schema>extracts the TypeScript type from a TypeBox schema, giving you type safety on both ends.