schema parameter that describes the fields you want. You can define schemas three ways: raw JSON, Pydantic models (Python), or Zod objects (TypeScript).
Typed JSON schema
Each field is an object with atype and description:
Supported types
| Type | Returns | Example value |
|---|---|---|
string | Text | "Acme Corp" |
number | Float | 1234.56 |
integer | Whole number | 42 |
boolean | true/false | true |
array | List | [{"item": "Widget", "qty": 3}] |
object | Nested object | {"street": "123 Main", "city": "NYC"} |
Enums
Constrain a field to specific allowed values:Required fields
Mark fields as required — the response will setsuccess: false if any required field is missing:
Arrays
Extract lists of items with a defined shape:Nested objects
Pydantic models (Python)
Pass a PydanticBaseModel class directly as the schema. The SDK converts it automatically — including nested models, Optional fields, Literal enums, and Field(description=...).
| Pydantic | Schema type |
|---|---|
str | string |
float | number |
int | integer |
bool | boolean |
list[T] | array with items |
Nested BaseModel | object with properties |
Optional[T] | Nullable field |
Literal["a", "b"] or Enum | string with enum |
Field(description="...") | Field description |
Zod schemas (TypeScript)
UsefromZod() to convert a Zod object schema. Supports z.string(), z.number(), z.boolean(), z.array(), z.object(), z.enum(), and .describe().
| Zod | Schema type |
|---|---|
z.string() | string |
z.number() | number |
z.boolean() | boolean |
z.array(T) | array with items |
z.object({...}) | object with properties |
z.enum([...]) | string with enum |
.optional() | Nullable field |
.describe("...") | Field description |
Type guarantees
When you define a field as"type": "number", the API guarantees the returned value is a JSON number — not a string like "$1,234.56". The AI parses, cleans, and type-coerces values automatically.
If a field can’t be found in the document, it returns null (not an empty string or zero).
Limits
- Maximum 10 top-level fields per request (excluding
_-prefixed meta keys) - No limit on nested properties within arrays or objects
- Descriptions improve accuracy — always include them