Module: RubyLLM::Agents::Audio::TranscriptionPricing
- Extended by:
- TranscriptionPricing
- Included in:
- TranscriptionPricing
- Defined in:
- lib/ruby_llm/agents/audio/transcription_pricing.rb
Overview
Dynamic pricing resolution for audio transcription models.
Cascades through multiple pricing sources to maximize coverage:
-
User config (instant, always wins)
-
RubyLLM gem (local, no HTTP, already a dependency)
-
LiteLLM (bulk, most comprehensive for transcription)
-
Portkey AI (per-model, good transcription coverage)
-
OpenRouter (bulk, audio-capable chat models only)
-
Helicone (text LLM only — pass-through, future-proof)
-
LLM Pricing AI (text LLM only — pass-through, future-proof)
When no pricing is found, methods return nil to signal the caller should warn the user with actionable configuration instructions.
All prices are per minute of audio.
Constant Summary collapse
- SOURCES =
[:config, :ruby_llm, :litellm, :portkey, :openrouter, :helicone, :llmpricing].freeze
Instance Method Summary collapse
-
#all_pricing ⇒ Hash
Expose all known pricing for debugging/console inspection.
-
#calculate_cost(model_id:, duration_seconds:) ⇒ Float?
Calculate total cost for a transcription operation.
-
#cost_per_minute(model_id) ⇒ Float?
Get cost per minute for a transcription model.
-
#pricing_found?(model_id) ⇒ Boolean
Check whether pricing is available for a model.
-
#refresh! ⇒ Object
Force refresh of cached pricing data.
Instance Method Details
#all_pricing ⇒ Hash
Expose all known pricing for debugging/console inspection
85 86 87 88 89 90 91 92 93 94 |
# File 'lib/ruby_llm/agents/audio/transcription_pricing.rb', line 85 def all_pricing { ruby_llm: {}, litellm: litellm_transcription_models, portkey: {}, openrouter: {}, helicone: {}, configured: config.transcription_model_pricing || {} } end |
#calculate_cost(model_id:, duration_seconds:) ⇒ Float?
Calculate total cost for a transcription operation
49 50 51 52 53 54 55 |
# File 'lib/ruby_llm/agents/audio/transcription_pricing.rb', line 49 def calculate_cost(model_id:, duration_seconds:) price = cost_per_minute(model_id) return nil unless price duration_minutes = duration_seconds / 60.0 (duration_minutes * price).round(6) end |
#cost_per_minute(model_id) ⇒ Float?
Get cost per minute for a transcription model
61 62 63 64 65 66 67 |
# File 'lib/ruby_llm/agents/audio/transcription_pricing.rb', line 61 def cost_per_minute(model_id) SOURCES.each do |source| price = send(:"from_#{source}", model_id) return price if price end nil end |
#pricing_found?(model_id) ⇒ Boolean
Check whether pricing is available for a model
73 74 75 |
# File 'lib/ruby_llm/agents/audio/transcription_pricing.rb', line 73 def pricing_found?(model_id) !cost_per_minute(model_id).nil? end |