Coolhand's Ruby SDK (coolhand-ruby) monitors LLM calls by patching into Ruby's standard HTTP library when you call Coolhand.configure. Two things make this different from Coolhand's Node and Python SDKs: it does not auto-initialize just by being required, and the require order that avoids problems is the opposite of what you'd naturally guess.
Require the provider gem before coolhand
# ❌ Wrong order — coolhand has nothing to patch yet
require 'coolhand'
require 'anthropic'
# ✅ Correct order — provider gem loads first, so coolhand has a class to prepend onto
require 'anthropic' # must come before coolhand
require 'coolhand'
Call Coolhand.configure explicitly during boot
In a plain Ruby app, call Coolhand.configure once at the start of your application. In Rails, put it in an initializer so it runs during boot, before any request or job can fire:
# ✅ config/initializers/coolhand.rb
Coolhand.configure do |c|
c.api_key = Rails.application.credentials.coolhand_api_key
c.silent = true
end
Declare workload context for captured calls
The Coolhand.with_context method lets you declare an identity for any calls made inside its block, which can help with analysis and cost attribution.
# ✅ Declare the workload for a call
Coolhand.with_context(workload: { key: "parser-v2" }) do
client.chat(parameters: { ... })
end
Don't install both a provider gem and its fork/alias
If you see duplicate requests in your logs, check whether you have more than one gem installed for the same provider (for example, anthropic and the older ruby-anthropic). If you do, remove the redundant one.
# ✅ Keep one provider gem per provider
gem uninstall ruby-anthropic
Verify interception in CI, not just a 200 response
An app that returns correct responses from your AI provider proves the provider integration works — it does not prove Coolhand captured it. Require order and missing Coolhand.configure calls both produce a fully working app with silently missing logs. If you have an integration test or example around your Coolhand setup, assert that a request was actually intercepted rather than just checking for a successful HTTP response.