Skip to main content
Source: conversation-metrics/ oh-metrics is a zero-dependency CLI tool that fetches cost and token usage for an OpenHands conversation. It automatically detects whether the conversation uses the V0 or V1 API and applies the appropriate retrieval strategy.

Installation

Or run the script directly (Python 3.10+ required):

Usage

Example Output

JSON Output

Pass --json for programmatic use:

Features

  • Auto-detects conversation version (V0 vs V1) and uses the appropriate API
  • Graceful fallback chain — tries multiple endpoints until one succeeds
  • JSON output for integration with dashboards or alerting pipelines
  • API call logging with --verbose for debugging
  • Zero dependencies — uses only the Python standard library
  • Fixture-based testing — high test coverage via recorded API responses

Getting a Conversation ID

Conversation IDs appear in the URL when you open a conversation:
You can also retrieve them programmatically:

See Also