chatWithImageSync method

Future<String> chatWithImageSync(
  1. String text,
  2. Uint8List imageBytes, {
  3. String? conversationId,
})

Send a multimodal chat message (text + image) - SYNC version

Implementation

Future<String> chatWithImageSync(
  String text,
  Uint8List imageBytes, {
  String? conversationId,
}) async {
  _assertInitialized();

  final convId = conversationId ?? _currentConversationId;
  if (convId == null) {
    throw StateError('No conversation. Call createConversation() first.');
  }

  final request = ChatWithImageRequest()
    ..conversationId = convId
    ..text = text
    ..image = imageBytes;

  final response = await _client!.chatWithImageSync(request);

  if (response.hasError() && response.error.isNotEmpty) {
    throw Exception('Chat error: ${response.error}');
  }

  return response.text;
}