Signal · Methods
signal.schema
signal.schema(zodSchema) sets the Zod schema for structured output. If the provider supports JSON Schema output, Signal sends the schema as a json_schema response_format; in every case the response is parsed and validated locally against the Zod schema, and the returned response is typed. The model’s reply is scripted; no model is called.
z.object({ show: z.string(), seats: z.number() }){
model: 'written-here',
messages: [
{
role: 'user',
content: 'Two for The Tempest on Saturday, please. Grace',
},
],
response_format: {
type: 'json_schema',
json_schema: {
name: 'output',
strict: false,
schema: {
$schema: 'http://json-schema.org/draft-07/schema#',
type: 'object',
properties: { show: { type: 'string' }, seats: { type: 'number' } },
required: ['show', 'seats'],
additionalProperties: false,
},
},
},
stream: true,
stream_options: { include_usage: true },
}{"show":"The Tempest","seats":2}{ show: 'The Tempest', seats: 2 }Runs in this page on the installed package. The input and the expected output are defined by the example.