Signal · Structured output

JSON mode fallback

For a provider that supports JSON mode but not JSON Schema output (Groq with its default model is one), Signal sends response_format: { type: 'json_object' } and appends the JSON Schema to the conversation as a system message. A provider without JSON mode gets the system message only, and the response is validated against the Zod schema in both cases. The model’s reply is scripted; no model is called.

Provider capabilities
{ nativeJsonMode: true }
Schema
z.object({ show: z.string(), seats: z.number() })
Conversation
user
  Two for The Tempest on Saturday, please. Grace
system
  OUTPUT SCHEMA: your final reply must be ONLY a JSON value matching this schema — raw
  JSON, no prose, no code fences:
  {"$schema":"http://json-schema.org/draft-07/schema#","type":"object",
  "properties":{"show":{"type":"string"},"seats":{"type":"number"}},
  "required":["show","seats"],"additionalProperties":false}
Rest of the request
{
  model: 'written-here',
  response_format: { type: 'json_object' },
  stream: true,
  stream_options: { include_usage: true },
}
Output
{ show: 'The Tempest', seats: 2 }
Output matches the expected value

Runs in this page on the installed package. The input and the expected output are defined by the example.