Structured Output
Validate model JSON with AIOS Schema.
Structured output validates the model response against a JSON Schema before you read it.
Schema to validated JSON
Build a schema with "AIOS Schema", attach it to the request, then read validated JSON from the result:
Schema: Codeunit "AIOS Schema";
Fields: List of [JsonObject];
Request: Record "AIOS Chat Request";
Result: Codeunit "AIOS Generate Result";
begin
Fields.Add(Schema.Field('summary', Schema.String()));
Fields.Add(Schema.Field('score', Schema.Number()));
Request.SetPrompt('Score this customer feedback');
Request.SetOutput(Schema.Object(Fields));
Result := Client.GenerateText(Model, Request);
// Result.Output() is validated JSON text
end;
Flat RecRef convenience
For binding into a record:
Request.SetOutput(RecRef);
Result := Client.GenerateText(Model, Request, RecRef);
// JSON fills bindable fields; raw JSON remains on Result.Output()
Flat RecRef binding fills record fields from the validated JSON. Use schema-validated JSON when you need a stable contract across versions.
With a tool loop, structured output and RecRef binding run on the final non-tool-call step only.