Skip to content

Commit f5e3806

Browse files
chore: replace deprecated .describe() with .meta() in docs (#322)
Updates all Zod schema examples in docs to use `.meta({ description: "..." })` instead of `.describe()`, which is the recommended approach in Zod 4+. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent e549268 commit f5e3806

10 files changed

Lines changed: 27 additions & 27 deletions

File tree

docs/api/ai.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ const weatherTool = toolDefinition({
302302
name: "getWeather",
303303
description: "Get the current weather for a city",
304304
inputSchema: z.object({
305-
city: z.string().describe("City name"),
305+
city: z.string().meta({ description: "City name" }),
306306
}),
307307
}).server(async ({ city }) => {
308308
// Implementation that fetches weather info

docs/guides/client-tools.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ export const updateUIDef = toolDefinition({
6565
name: "update_ui",
6666
description: "Update the UI with new information",
6767
inputSchema: z.object({
68-
message: z.string().describe("Message to display"),
69-
type: z.enum(["success", "error", "info"]).describe("Message type"),
68+
message: z.string().meta({ description: "Message to display" }),
69+
type: z.enum(["success", "error", "info"]).meta({ description: "Message type" }),
7070
}),
7171
outputSchema: z.object({
7272
success: z.boolean(),
@@ -77,8 +77,8 @@ export const saveToLocalStorageDef = toolDefinition({
7777
name: "save_to_local_storage",
7878
description: "Save data to browser local storage",
7979
inputSchema: z.object({
80-
key: z.string().describe("Storage key"),
81-
value: z.string().describe("Value to store"),
80+
key: z.string().meta({ description: "Storage key" }),
81+
value: z.string().meta({ description: "Value to store" }),
8282
}),
8383
outputSchema: z.object({
8484
saved: z.boolean(),

docs/guides/server-tools.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const getUserDataDef = toolDefinition({
6060
name: "get_user_data",
6161
description: "Get user information from the database",
6262
inputSchema: z.object({
63-
userId: z.string().describe("The user ID to look up"),
63+
userId: z.string().meta({ description: "The user ID to look up" }),
6464
}),
6565
outputSchema: z.object({
6666
name: z.string(),
@@ -93,7 +93,7 @@ const getUserDataDef = toolDefinition({
9393
name: "get_user_data",
9494
description: "Get user information from the database",
9595
inputSchema: z.object({
96-
userId: z.string().describe("The user ID to look up"),
96+
userId: z.string().meta({ description: "The user ID to look up" }),
9797
}),
9898
outputSchema: z.object({
9999
name: z.string(),
@@ -118,8 +118,8 @@ const searchProductsDef = toolDefinition({
118118
name: "search_products",
119119
description: "Search for products in the catalog",
120120
inputSchema: z.object({
121-
query: z.string().describe("Search query"),
122-
limit: z.number().optional().describe("Maximum number of results"),
121+
query: z.string().meta({ description: "Search query" }),
122+
limit: z.number().optional().meta({ description: "Maximum number of results" }),
123123
}),
124124
});
125125

docs/guides/structured-outputs.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ TanStack AI uses **Standard JSON Schema**, which means you can use any schema li
3131
- [Valibot](https://valibot.dev/) (via `@valibot/to-json-schema`)
3232
- Plain JSON Schema objects
3333

34-
> **Note:** Refer to your schema library's documentation for details on defining schemas and using features like `.describe()` for field descriptions. TanStack AI will convert your schema to JSON Schema format automatically.
34+
> **Note:** Refer to your schema library's documentation for details on defining schemas and using features like `.meta()` for field descriptions. TanStack AI will convert your schema to JSON Schema format automatically.
3535
3636
## Basic Usage
3737

@@ -44,9 +44,9 @@ import { z } from "zod";
4444

4545
// Define your schema
4646
const PersonSchema = z.object({
47-
name: z.string().describe("The person's full name"),
48-
age: z.number().describe("The person's age in years"),
49-
email: z.string().email().describe("The person's email address"),
47+
name: z.string().meta({ description: "The person's full name" }),
48+
age: z.number().meta({ description: "The person's age in years" }),
49+
email: z.string().email().meta({ description: "The person's email address" }),
5050
});
5151

5252
// Use it with chat()
@@ -112,16 +112,16 @@ recipe.instructions.map((step) => step.toUpperCase()); // string[]
112112

113113
## Using Field Descriptions
114114

115-
Schema field descriptions help the AI understand what data to extract. Most schema libraries support a `.describe()` method:
115+
Schema field descriptions help the AI understand what data to extract. In Zod 4+, use the `.meta()` method:
116116

117117
```typescript
118118
const ProductSchema = z.object({
119-
name: z.string().describe("The product name"),
120-
price: z.number().describe("Price in USD"),
121-
inStock: z.boolean().describe("Whether the product is currently available"),
119+
name: z.string().meta({ description: "The product name" }),
120+
price: z.number().meta({ description: "Price in USD" }),
121+
inStock: z.boolean().meta({ description: "Whether the product is currently available" }),
122122
categories: z
123123
.array(z.string())
124-
.describe("Product categories like 'electronics', 'clothing', etc."),
124+
.meta({ description: "Product categories like 'electronics', 'clothing', etc." }),
125125
});
126126
```
127127

@@ -134,7 +134,7 @@ You can define deeply nested structures:
134134
```typescript
135135
const CompanySchema = z.object({
136136
name: z.string(),
137-
founded: z.number().describe("Year the company was founded"),
137+
founded: z.number().meta({ description: "Year the company was founded" }),
138138
headquarters: z.object({
139139
city: z.string(),
140140
country: z.string(),
@@ -149,7 +149,7 @@ const CompanySchema = z.object({
149149
),
150150
financials: z
151151
.object({
152-
revenue: z.number().describe("Annual revenue in millions USD"),
152+
revenue: z.number().meta({ description: "Annual revenue in millions USD" }),
153153
profitable: z.boolean(),
154154
})
155155
.optional(),

docs/guides/tools.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Zod schemas provide full TypeScript type inference and runtime validation:
4848
import { z } from "zod";
4949

5050
const inputSchema = z.object({
51-
location: z.string().describe("City name"),
51+
location: z.string().meta({ description: "City name" }),
5252
unit: z.enum(["celsius", "fahrenheit"]).optional(),
5353
});
5454
```
@@ -91,7 +91,7 @@ const getWeatherDef = toolDefinition({
9191
name: "get_weather",
9292
description: "Get the current weather for a location",
9393
inputSchema: z.object({
94-
location: z.string().describe("The city and state, e.g. San Francisco, CA"),
94+
location: z.string().meta({ description: "The city and state, e.g. San Francisco, CA" }),
9595
unit: z.enum(["celsius", "fahrenheit"]).optional(),
9696
}),
9797
outputSchema: z.object({

docs/reference/functions/convertSchemaToJsonSchema.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ JSON Schema object that can be sent to LLM providers
4848
import * as z from 'zod';
4949

5050
const zodSchema = z.object({
51-
location: z.string().describe('City name'),
51+
location: z.string().meta({ description: 'City name' }),
5252
unit: z.enum(['celsius', 'fahrenheit']).optional()
5353
});
5454

docs/reference/interfaces/ServerTool.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ Standard JSON Schema compliant schemas are converted to JSON Schema for LLM prov
138138
// Using Zod v4+ schema (natively supports Standard JSON Schema)
139139
import { z } from 'zod';
140140
z.object({
141-
location: z.string().describe("City name or coordinates"),
141+
location: z.string().meta({ description: "City name or coordinates" }),
142142
unit: z.enum(["celsius", "fahrenheit"]).optional()
143143
})
144144
```

docs/reference/interfaces/Tool.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ Standard JSON Schema compliant schemas are converted to JSON Schema for LLM prov
133133
// Using Zod v4+ schema (natively supports Standard JSON Schema)
134134
import { z } from 'zod';
135135
z.object({
136-
location: z.string().describe("City name or coordinates"),
136+
location: z.string().meta({ description: "City name or coordinates" }),
137137
unit: z.enum(["celsius", "fahrenheit"]).optional()
138138
})
139139
```

docs/reference/interfaces/ToolDefinition.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ Standard JSON Schema compliant schemas are converted to JSON Schema for LLM prov
166166
// Using Zod v4+ schema (natively supports Standard JSON Schema)
167167
import { z } from 'zod';
168168
z.object({
169-
location: z.string().describe("City name or coordinates"),
169+
location: z.string().meta({ description: "City name or coordinates" }),
170170
unit: z.enum(["celsius", "fahrenheit"]).optional()
171171
})
172172
```

docs/reference/interfaces/ToolDefinitionInstance.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ Standard JSON Schema compliant schemas are converted to JSON Schema for LLM prov
142142
// Using Zod v4+ schema (natively supports Standard JSON Schema)
143143
import { z } from 'zod';
144144
z.object({
145-
location: z.string().describe("City name or coordinates"),
145+
location: z.string().meta({ description: "City name or coordinates" }),
146146
unit: z.enum(["celsius", "fahrenheit"]).optional()
147147
})
148148
```

0 commit comments

Comments
 (0)