Define a complete API with schema-first validation. Identity function — returns the object as-is but enables InferAPI<typeof api>.
InferAPI<typeof api>
const api = defineAPI({ echo: defineMethod({ input: z.tuple([z.string()]), output: z.string() }, async (msg) => msg), math: { add: defineMethod({ input: z.tuple([z.number(), z.number()]), output: z.number() }, async (a, b) => a + b), }}) Copy
const api = defineAPI({ echo: defineMethod({ input: z.tuple([z.string()]), output: z.string() }, async (msg) => msg), math: { add: defineMethod({ input: z.tuple([z.number(), z.number()]), output: z.number() }, async (a, b) => a + b), }})
Define a complete API with schema-first validation. Identity function — returns the object as-is but enables
InferAPI<typeof api>.