Skip to content

Gemini CLI Source

  • ~/.gemini/tmp/*/chats/*.json (or $GEMINI_CLI_HOME/tmp/*/chats/*.json when GEMINI_CLI_HOME is set)
Terminal window
llm-usage daily --gemini-dir /path/to/.gemini
# or
llm-usage daily --source-dir gemini=/path/to/.gemini
  • each file is a single JSON session object
  • only message.type === "gemini" rows with token usage are emitted
  • token mapping:
    • tokens.input - tokens.cached + tokens.tool → inputTokens (Gemini’s input already includes cached input)
    • tokens.output + tokens.thoughts → outputTokens (thinking tokens are billed at the output rate)
    • tokens.thoughts → reasoningTokens (a breakdown of output, as for other sources)
    • tokens.cached → cacheReadTokens
    • tokens.total → totalTokens when present
  • repoRoot is resolved from projects.json in the Gemini directory ($GEMINI_CLI_HOME, --gemini-dir, or ~/.gemini) when available. The file maps each project root to its tmp/<name> directory, and a session’s projectHash is the SHA-256 of that root, so sessions resolve by hash first and by tmp/<name> otherwise. The older {"<id>": {"absolutePath": ...}} layout is still read. When several roots map to the same tmp/<name>, the last entry in projects.json wins.