Skip to main content
Use a JSON schema when your application consumes the response.

Define the response contract

A prompt can ask for JSON, but it cannot guarantee valid JSON. A schema defines the expected fields, types, required values, and allowed enums. SERV forwards the schema to a compatible upstream provider and preserves the structured response format.
Validate the result at your application boundary. Handle refusals, truncation, invalid JSON, and invalid field values separately. Keep the schema small and use enums wherever the valid values are known. If the provider cannot honor the requested format, fail visibly rather than silently treating prose as valid application data.