text property

  1. @override
String? get text
override

Get the text content of the response

Implementation

@override
String? get text {
  // First try the Responses API format
  final output = _rawResponse['output'] as List?;
  if (output != null) {
    // Look for message items in the output array
    for (final item in output) {
      if (item is Map<String, dynamic> && item['type'] == 'message') {
        final content = item['content'] as List?;
        if (content != null) {
          // Find text content in the content array
          for (final contentItem in content) {
            if (contentItem is Map<String, dynamic> &&
                contentItem['type'] == 'output_text') {
              return contentItem['text'] as String?;
            }
          }
        }
      }
    }
  }

  // Fallback to legacy format
  return _rawResponse['output_text'] as String?;
}