Type Alias: Structure
@providerprotocol/ai / @providerprotocol/ai / Structure
Type Alias: Structure
Section titled “Type Alias: Structure”Structure =
JSONSchema|ZodLike
Defined in: src/types/schema.ts:222
Structure input type that accepts either JSON Schema or Zod schemas.
When a Zod schema is provided, it will be automatically converted to JSON Schema before being sent to the provider.
Example
Section titled “Example”import { z } from 'zod';
// Using Zod schema directlyconst model = llm({ model: anthropic('claude-sonnet-4-20250514'), structure: z.object({ name: z.string(), age: z.number(), }),});
// Using JSON Schemaconst model = llm({ model: anthropic('claude-sonnet-4-20250514'), structure: { type: 'object', properties: { name: { type: 'string' }, age: { type: 'number' }, }, required: ['name', 'age'], },});