function convertZodToJsonSchema(schema): Record<string, any> | undefined;
function convertZodToJsonSchema(schema): Record<string, any> | undefined;
Defined in: tools/zod-converter.ts:31
Converts a Zod schema to JSON Schema format compatible with LLM providers.
Zod schema to convert
ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>> | undefined
Record<string, any> | undefined
JSON Schema object that can be sent to LLM providers
import { z } from 'zod';
const schema = z.object({
location: z.string().describe('City name'),
unit: z.enum(['celsius', 'fahrenheit']).optional()
});
const jsonSchema = convertZodToJsonSchema(schema);
// Returns:
// {
// type: 'object',
// properties: {
// location: { type: 'string', description: 'City name' },
// unit: { type: 'string', enum: ['celsius', 'fahrenheit'] }
// },
// required: ['location']
// }
import { z } from 'zod';
const schema = z.object({
location: z.string().describe('City name'),
unit: z.enum(['celsius', 'fahrenheit']).optional()
});
const jsonSchema = convertZodToJsonSchema(schema);
// Returns:
// {
// type: 'object',
// properties: {
// location: { type: 'string', description: 'City name' },
// unit: { type: 'string', enum: ['celsius', 'fahrenheit'] }
// },
// required: ['location']
// }
