Module: LlmCostTracker::Integrations::Anthropic::MessagesPatch

Defined in:
lib/llm_cost_tracker/integrations/anthropic.rb

Instance Method Summary collapse

Instance Method Details

#create(*args, **kwargs) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/llm_cost_tracker/integrations/anthropic.rb', line 61

def create(*args, **kwargs)
  started_at = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  LlmCostTracker::Integrations::Anthropic.enforce_budget!
  message = super
  LlmCostTracker::Integrations::Anthropic.record_message(
    message,
    request: LlmCostTracker::Integrations::Anthropic.request_params(args, kwargs),
    latency_ms: LlmCostTracker::Integrations::Anthropic.elapsed_ms(started_at)
  )
  message
end