RubyFlow The Ruby and Rails community linklog

×

The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

Self-hosted LLM Cost Tracker for Rails – v0.5.3 Released

I’ve just released v0.5.3 of llm_cost_tracker — a lightweight, self-hosted gem designed to track LLM API costs directly inside Ruby and Rails applications.

As LLMs become more common in Rails apps (chat, agents, RAG, summarization, etc.), many teams need a clear understanding of real usage and costs — ideally broken down by user, tenant, or feature — without sending prompts through third-party services.

What llm_cost_tracker offers:
- Stores all cost data in your own database (ActiveRecord)
- Privacy-first: does not store prompts or responses
- Automatic instrumentation for official openai and anthropic SDKs
- Faraday middleware support for ruby-openai, OpenRouter, Gemini, and other OpenAI-compatible clients
- Significantly improved streaming support in v0.5.3 (official SDK streaming now works reliably)
- Flexible tagging (user_id, tenant_id, feature, etc.)
- Simple budget guardrails (monthly, daily, or per-request limits)
- Minimalist dashboard as a Rails Engine (no JavaScript)

The gem is still early-stage (just a couple of weeks old), but built with a focus on simplicity, reliability, and staying Rails-native. I’d really appreciate any feedback from the Ruby community — especially from developers already using LLMs in production.

Repo: https://github.com/sergey-homenko/llm_cost_tracker
Gem: https://rubygems.org/gems/llm_cost_tracker

Looking forward to your thoughts, suggestions, or bug reports!

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in