@@ -444,6 +444,17 @@ public readonly struct UsageMetadata {
444444 /// </summary>
445445 public int CandidatesTokenCount { get ; }
446446 /// <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>
447458 /// The total number of tokens in both the request and response.
448459 /// </summary>
449460 public int TotalTokenCount { get ; }
@@ -463,10 +474,11 @@ public IEnumerable<ModalityTokenCount> CandidatesTokensDetails {
463474 }
464475
465476 // 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 ,
467478 List < ModalityTokenCount > promptDetails , List < ModalityTokenCount > candidateDetails ) {
468479 PromptTokenCount = promptTC ;
469480 CandidatesTokenCount = candidatesTC ;
481+ ThoughtsTokenCount = thoughtsTC ;
470482 TotalTokenCount = totalTC ;
471483 _promptTokensDetails =
472484 new ReadOnlyCollection < ModalityTokenCount > ( promptDetails ?? new List < ModalityTokenCount > ( ) ) ;
@@ -483,6 +495,7 @@ internal static UsageMetadata FromJson(Dictionary<string, object> jsonDict) {
483495 return new UsageMetadata (
484496 jsonDict . ParseValue < int > ( "promptTokenCount" ) ,
485497 jsonDict . ParseValue < int > ( "candidatesTokenCount" ) ,
498+ jsonDict . ParseValue < int > ( "thoughtsTokenCount" ) ,
486499 jsonDict . ParseValue < int > ( "totalTokenCount" ) ,
487500 jsonDict . ParseObjectList ( "promptTokensDetails" , ModalityTokenCount . FromJson ) ,
488501 jsonDict . ParseObjectList ( "candidatesTokensDetails" , ModalityTokenCount . FromJson ) ) ;
0 commit comments