generateStructured method

Future<Map<String, dynamic>> generateStructured({
  1. required String prompt,
  2. required Map<String, dynamic> schema,
  3. String? instructions,
  4. List<Uint8List> images = const [],
  5. String schemaName = 'Response',
  6. double? temperature,
  7. int? maxTokens,
  8. Duration? timeout,
})

Generates a JSON object that is guaranteed to match schema.

schema is a JSON-Schema subset: object (with properties and required), array (with items, minItems, maxItems), string, number, integer, boolean, enum of strings, and description on any node. Properties are generated in the order they are written.

images are encoded image bytes (JPEG, PNG, HEIC). They need iOS 27 and NativeAiCapabilities.vision; otherwise the call throws VISION_UNSUPPORTED.

Implementation

Future<Map<String, dynamic>> generateStructured({
  required String prompt,
  required Map<String, dynamic> schema,
  String? instructions,
  List<Uint8List> images = const [],
  String schemaName = 'Response',
  double? temperature,
  int? maxTokens,
  Duration? timeout,
}) {
  return AppleFoundationFlutterPlatform.instance.generateStructured(
    prompt: prompt,
    schema: schema,
    instructions: instructions,
    images: images,
    schemaName: schemaName,
    temperature: temperature,
    maxTokens: maxTokens,
    timeout: timeout,
  );
}