SDK ReferenceFunctions
schemaFromZod()
Function: schemaFromZod()
schemaFromZod(
name,zodSchema,opts?):Promise<{embed_template?:string;json_schema:RecordSchemaDef;name:string; }>
Defined in: packages/sdk/src/backend/records.ts:187
Convert a Zod object schema to a Libra schema definition (Zod ≥3.24 / v4 —
needs z.toJSONSchema). zod is an optional peer: if it isn't installed,
use defineSchema instead. Only the restricted subset survives —
nested objects, unions, or non-string arrays are rejected server-side.
const Link = z.object({ href: z.string(), note: z.string().optional() });
await records.createSchema(await schemaFromZod("link", Link));Parameters
name
string
zodSchema
opts?
embedTemplate?
string
Returns
Promise<{ embed_template?: string; json_schema: RecordSchemaDef; name: string; }>