@@ -444,6 +444,17 @@ public readonly struct UsageMetadata {
444
444
/// </summary>
445
445
public int CandidatesTokenCount { get ; }
446
446
/// <summary>
447
+ /// The number of tokens used by the model's internal "thinking" process.
448
+ ///
449
+ /// For models that support thinking (like Gemini 2.5 Pro and Flash), this represents the actual
450
+ /// number of tokens consumed for reasoning before the model generated a response. For models
451
+ /// that do not support thinking, this value will be `0`.
452
+ ///
453
+ /// When thinking is used, this count will be less than or equal to the `thinkingBudget` set in
454
+ /// the `ThinkingConfig`.
455
+ /// </summary>
456
+ public int ThoughtsTokenCount { get ; }
457
+ /// <summary>
447
458
/// The total number of tokens in both the request and response.
448
459
/// </summary>
449
460
public int TotalTokenCount { get ; }
@@ -463,10 +474,11 @@ public IEnumerable<ModalityTokenCount> CandidatesTokensDetails {
463
474
}
464
475
465
476
// Hidden constructor, users don't need to make this.
466
- private UsageMetadata ( int promptTC , int candidatesTC , int totalTC ,
477
+ private UsageMetadata ( int promptTC , int candidatesTC , int thoughtsTC , int totalTC ,
467
478
List < ModalityTokenCount > promptDetails , List < ModalityTokenCount > candidateDetails ) {
468
479
PromptTokenCount = promptTC ;
469
480
CandidatesTokenCount = candidatesTC ;
481
+ ThoughtsTokenCount = thoughtsTC ;
470
482
TotalTokenCount = totalTC ;
471
483
_promptTokensDetails =
472
484
new ReadOnlyCollection < ModalityTokenCount > ( promptDetails ?? new List < ModalityTokenCount > ( ) ) ;
@@ -483,6 +495,7 @@ internal static UsageMetadata FromJson(Dictionary<string, object> jsonDict) {
483
495
return new UsageMetadata (
484
496
jsonDict . ParseValue < int > ( "promptTokenCount" ) ,
485
497
jsonDict . ParseValue < int > ( "candidatesTokenCount" ) ,
498
+ jsonDict . ParseValue < int > ( "thoughtsTokenCount" ) ,
486
499
jsonDict . ParseValue < int > ( "totalTokenCount" ) ,
487
500
jsonDict . ParseObjectList ( "promptTokensDetails" , ModalityTokenCount . FromJson ) ,
488
501
jsonDict . ParseObjectList ( "candidatesTokensDetails" , ModalityTokenCount . FromJson ) ) ;
0 commit comments