Skip to content

thepetk/robotheus

Repository files navigation

Robotheus

Python 3.12+ Tests Release

Multi-provider AI Prometheus exporter. Collects usage and cost metrics from AI providers and exposes them in Prometheus format.

Currently supported providers:

  • OpenAI — token usage, request counts, and cost data via the Organization API

Metrics

OpenAI

Metric Type Labels Description
robotheus_openai_requests_total Counter model, project, api_key_id Total API requests
robotheus_openai_tokens_total Counter model, project, api_key_id, direction Total tokens (direction: input or output)
robotheus_openai_cost_usd_total Counter project Cumulative cost in USD since exporter start
robotheus_openai_cost_usd_today Gauge project Cost in USD since midnight UTC today
robotheus_openai_cost_usd_week Gauge project Cost in USD over the last 7 days
robotheus_openai_cost_usd_month Gauge project Cost in USD over the last 30 days
robotheus_openai_cost_usd_daily Gauge project, date Cost in USD per calendar day (date: YYYY-MM-DD), used for week/month time series panels

Quickstart

Prerequisites

  • Python 3.12+
  • uv

Run locally

export OPENAI_API_KEY="sk-..."
uv run robotheus

CLI flags

Flag Default Description
--web.listen-address :9185 Listen address
--scrape.interval 60 Usage scrape interval in seconds
--cost.window-interval 1800 How often to refresh the cost window gauges (today/week/month) in seconds
--log.level info Log level (debug, info, warning, error)

Environment variables

Variable Required Description
OPENAI_API_KEY Yes OpenAI API key
OPENAI_ORG_ID No OpenAI Organization ID

Docker

docker run -e OPENAI_API_KEY="sk-..." -p 9185:9185 ghcr.io/thepetk/robotheus:latest

Development

# install dependencies
uv sync --all-extras

# run tests
make test

# run linter
make ruff

# run type checker
make ty

# install pre-commit hooks
make pre-commit-install

Contributing

You're more than welcome to contribute to the project. Feel free to open a PR!

About

A Python Prometheus exporter for AI provider cost & usage metrics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages