TranscriptionUsage.fromJson constructor

TranscriptionUsage.fromJson(
  1. Map<String, dynamic> j
)

Deserialise from JSON, dispatching to the correct concrete class.

Implementation

factory TranscriptionUsage.fromJson(Map<String, dynamic> j) {
  switch (j['type']) {
    case 'tokens':
      return TranscriptionUsageTokens.fromJson(j);
    case 'duration':
      return TranscriptionUsageDuration.fromJson(j);
    default:
      // Handle unknown types gracefully if necessary
      throw ArgumentError('Unknown TranscriptionUsage type: "${j['type']}"');
  }
}