Gemini.Types.Live.UsageMetadata (GeminiEx v0.11.0)

Copy Markdown View Source

Usage metadata for Live API responses.

Contains token count information about the request and response, including breakdowns by modality.

Fields

  • prompt_token_count - Number of tokens in the prompt
  • cached_content_token_count - Number of tokens in cached content
  • response_token_count - Total tokens across all response candidates
  • tool_use_prompt_token_count - Tokens in tool-use prompts
  • thoughts_token_count - Tokens used for thinking
  • total_token_count - Total token count (prompt + response)
  • prompt_tokens_details - Token counts by modality for input
  • cache_tokens_details - Token counts by modality for cached content
  • response_tokens_details - Token counts by modality for response
  • tool_use_prompt_tokens_details - Token counts by modality for tool use

Example

%UsageMetadata{
  prompt_token_count: 100,
  response_token_count: 50,
  total_token_count: 150
}

Summary

Functions

Parses from API response.

Creates a new UsageMetadata.

Converts to API format (camelCase).

Types

modality_token_count()

@type modality_token_count() :: %{
  modality: String.t() | nil,
  token_count: integer() | nil
}

t()

@type t() :: %Gemini.Types.Live.UsageMetadata{
  cache_tokens_details: [modality_token_count()] | nil,
  cached_content_token_count: integer() | nil,
  prompt_token_count: integer() | nil,
  prompt_tokens_details: [modality_token_count()] | nil,
  response_token_count: integer() | nil,
  response_tokens_details: [modality_token_count()] | nil,
  thoughts_token_count: integer() | nil,
  tool_use_prompt_token_count: integer() | nil,
  tool_use_prompt_tokens_details: [modality_token_count()] | nil,
  total_token_count: integer() | nil
}

Functions

from_api(data)

@spec from_api(map() | nil) :: t() | nil

Parses from API response.

new(opts \\ [])

@spec new(keyword()) :: t()

Creates a new UsageMetadata.

to_api(value)

@spec to_api(t() | nil) :: map() | nil

Converts to API format (camelCase).