Skip to main content Switch to mobile version coolhand 0.13.0 A Python SDK for monitoring and analyzing AI API interactions with LLM services
pip install coolhand==0.13.0 Copy PIP instructions
Monitor and log LLM API calls from OpenAI, Anthropic, Google Gemini, GitHub Copilot, Vertex AI, OpenRouter, OpenCode, Cloudflare AI Gateway, ElevenLabs, DeepSeek, Mistral, Perplexity, xAI, Cohere, Amazon Bedrock, Ollama, and more — including pydantic-ai and Dramatiq — to the Coolhand analytics platform.
Python 3.8 and 3.9 support deprecated: As of v0.4.0, coolhand requires Python 3.10 or later. Python 3.8 reached end-of-life in October 2024 and 3.9 in October 2025. If you are on an older Python version, pin to coolhand<0.4.0.
pip install coolhand Getting Started
Get API Key: Visit coolhandlabs.com to create a free account
Install: pip install coolhand
Configure: Set COOLHAND_API_KEY and import coolhand in your app
Deploy: Your AI calls are now automatically monitored!
Automatic Global Monitoring
Set it and forget it! Monitor ALL AI API calls across your entire application with minimal configuration.
import coolhand # Auto-initializes and starts monitoring # That's it! ALL AI API calls are now automatically monitored: # ✅ OpenAI SDK calls # ✅ Anthropic API calls # ✅ Google Gemini API calls # ✅ GitHub Copilot SDK calls # ✅ ANY library making AI API calls via httpx or httpx2 # Your existing code works unchanged: from openai import OpenAI client = OpenAI() response = client.chat.completions.create( model="gpt-4", messages=[{"role": "user", "content": "Hello!"}] ) # The request and response have been automatically logged to Coolhand! Why Automatic Monitoring:
Zero refactoring - No code changes to existing services
Complete coverage - Monitors all AI libraries using httpx or httpx2 automatically
Security built-in - Automatic credential sanitization
Performance optimized - Negligible overhead via async logging
Future-proof - Automatically captures new AI calls added by your team
from coolhand import Coolhand coolhand_client = Coolhand( api_key='your-api-key', silent=False, # Enable verbose logging ) For excluding noisy endpoints (health checks, batch jobs), pointing the SDK at a self-hosted backend, or raising the Coolhand API request timeout (request_timeout, default 30 seconds), see Advanced Configuration.
import coolhand from openai import OpenAI client = OpenAI() response = client.chat.completions.create( model="gpt-4", messages=[{"role": "user", "content": "Hello!"}] ) print(response.choices[0].message.content) # Request automatically logged to Coolhand! With Anthropic
import coolhand from anthropic import Anthropic client = Anthropic() response = client.messages.create( model="claude-3-opus-20240229", max_tokens=1024, messages=[{"role": "user", "content": "Hello!"}] ) print(response.content[0].text) # Request automatically logged to Coolhand! With Google Gemini
import coolhand import google.generativeai as genai genai.configure(api_key="your-gemini-api-key") model = genai.GenerativeModel("gemini-pro") response = model.generate_content("Hello!") print(response.text) # Request automatically logged to Coolhand! With GitHub Copilot SDK
import coolhand # GitHub Copilot SDK calls are automatically intercepted # via JsonRpcClient patching — no additional setup needed. With Streaming
Request Data: Method, URL, headers, request body
Response Data: Status code, headers, response body
Timing: Request timestamp, response timestamp, duration
LLM-Specific: Model used, token counts, streaming status
Headers containing API keys, sensitive URL query parameters, and credentials embedded in request and response bodies (such as MCP server tokens and Azure OpenAI On Your Data) are automatically redacted. See Supported Libraries for the exact scope.
Coolhand works with any library that uses httpx, httpx2, requests, or the GitHub Copilot SDK:
Google Gemini (google-generativeai / google-genai)
Azure OpenAI (including Azure Government and Azure China endpoints)
Azure AI Foundry / Azure AI Inference (azure-ai-inference)
Azure Machine Learning managed online endpoints
Cohere (v2 chat, v1/v2 embed)
Ollama (non-localhost hosts on the default port, e.g. http://ollama:11434)
Any other library using httpx, httpx2 or requests
See Supported Libraries for the full interception mechanism breakdown and streaming details.
Importing coolhand patches httpx, httpx2, requests, and the GitHub Copilot JsonRpcClient at the class level. Requests to LLM APIs are intercepted, credentials are redacted, and data is submitted to Coolhand. Non-LLM requests pass through unchanged.
Collect user feedback on LLM responses to improve your AI outputs.
Frontend Feedback Widget: For browser-based feedback collection, see coolhand-js.
from coolhand import Coolhand ch = Coolhand(api_key='your-api-key') # Submit positive feedback ch.create_feedback({ 'llm_request_log_id': 'abc123def456', # hashid from a prior response; a raw integer FK also still works 'sentiment': 'like', 'explanation': 'Very helpful response!' }) # Submit negative feedback with a correction ch.create_feedback({ 'original_output': 'The capital of France is London.', 'sentiment': 'dislike', 'revised_output': 'The capital of France is Paris.' }) Running inside an event loop (e.g. an async web handler)? Use await ch.acreate_feedback(...) instead — same fields, same result, non-blocking.
For the full field reference, matching strategies, sentiment values, and async usage, see Feedback API.
search_templates and get_template read back the LLM request templates your logs are matched against. Unlike the monitoring and feedback calls, these require your private API key (the public key is write-only and 401s):
These are read methods, so they raise CoolhandAPIError (carrying the HTTP status on .status) rather than returning None the way create_feedback does — a caller needs to tell a 404 from a retryable 504.
For the full filter reference, pagination, and error handling, see Reading Templates.
Declaring Workloads and Templates
If you already know which workload and template an LLM call belongs to, declare it with with_context and the server skips template matching for those calls:
from coolhand import with_context with with_context(workload={"key": "Parser#call"}, template={"key": "Parser#call/squish:L2"}): client.chat.completions.create(...) Invalid declarations raise ValueError before your code runs. WorkloadService.upsert and TemplateService.upsert create or rename workloads and templates explicitly (private API key). See Declared Workloads and Templates.
Reading Workloads and Cost Metrics
search_workloads lists your workloads, and include_metrics adds the dashboard's cost and performance numbers to workloads and templates, over a rolling days_back window or an explicit since/until one. search_logs returns a per-log cost and can filter and sort on it, and failure_summary rolls failed requests up by error pattern. All need your private API key:
from datetime import datetime, timezone workloads = ch.search_workloads(include_metrics=True, days_back=30)['workloads'] workloads[0]['metrics']['total_cost'] logs = ch.search_logs( since=datetime(2026, 9, 1, tzinfo=timezone.utc), min_cost=0.5, order='cost_desc', )['logs'] summary = ch.failure_summary(days_back=30) if summary['error_breakdown']: pattern = summary['error_breakdown'][0]['error_pattern'] failed = ch.search_logs(error_contains=pattern, days_back=30)['logs'] See Reading Workloads for the workload reference, Reading Templates for the metrics fields and window rules, and Reading Logs for log search, get_log and failure_summary.
get_realized_savings returns what switching templates or models has saved you, in total and per workload (the dashboard's figure). It needs your private API key and takes no parameters:
savings = ch.get_realized_savings() savings['total'], savings['percent'], savings['workloads'] The comparison window is fixed server-side and is not windowed by days_back, unlike workload metrics; join the two on workload id. A 503 raises CoolhandAPIError and means it could not be computed, not zero savings. See Reading Realized Savings.
HelpCenterDocs reads the Coolhand help center (the same pages as coolhandlabs.com/help and /updates). It needs no API key, so it works without a Coolhand instance:
from coolhand import HelpCenterDocs help_center = HelpCenterDocs() result = help_center.search_help_articles(query='match rate', per_page=5) article = help_center.get_help_article(result['articles'][0]['slug']) # full markdown `body` categories = help_center.list_help_categories() Anonymous callers are limited to 30 requests per minute per IP. If api_key is passed (or COOLHAND_API_KEY is set) it is sent and lifts the limit; a key the server rejects is a 401. A Coolhand instance exposes the same three methods and sends its own key. See Reading the Help Center for parameters, the category filter and errors.
Linking Feedback to an Optimization
link_feedback, bulk_link_feedback (batches of 100) and unlink_feedback attach feedback to an optimization as evidence. Private API key required; errors raise CoolhandAPIError. See Linking Feedback.
export COOLHAND_SILENT=false Verify Interception in Your Tests
A client that captured a reference to httpx.Client.send, httpx2.Client.send or requests.Session.send before import coolhand is silently not monitored. Catch it in your own tests:
from coolhand.testing import assert_interception_occurred, capture_interception_snapshot before = capture_interception_snapshot() client.chat.completions.create(...) assert_interception_occurred(before, "openai client bypassed Coolhand") See Verifying Interception in Your Tests for what it catches and its limits.
Sign up for free at coolhandlabs.com to get your API key and start monitoring your LLM usage.
Complete LLM request and response logging
Usage analytics and insights
No credit card required to start
API keys in request headers are automatically redacted
Sensitive URL query parameters (key, api_key, token, etc.) are automatically redacted
Datastore credentials embedded in request bodies (e.g. Azure OpenAI On Your Data) are automatically redacted
Well-known credential fields in request and response bodies (such as MCP server tokens and client_secret) are automatically redacted; see Supported Libraries
No sensitive data is exposed in logs
All data is sent via HTTPS to Coolhand servers
Advanced Configuration — exclude patterns, self-hosted deployments, custom intercept addresses
Feedback API — full field reference, matching strategies, sentiment values, async usage
Supported Libraries — interception mechanisms, streaming, thread/process safety, delivery model
Verifying Interception in Your Tests — assert in your own tests/CI that a request was actually intercepted
Dramatiq + pydantic-ai — task queue integration guide, known gaps, workarounds
Reading Templates — search LLM request templates and fetch a single one, prompt patterns included, using the private API key
Declared Workloads and Templates — declare the workload/template of captured calls with with_context, and create or rename them with upsert (private API key)
Examples and live smoke tests — runnable examples, plus make live-examples to validate OpenAI and Anthropic calls against real keys
Reading Workloads — list workloads with cost and performance metrics over a rolling or explicit window
Reading Realized Savings — get what switching templates or models has saved you, in total and per workload, using the private API key
Reading Logs — search logs by cost, time window and more, and fetch one log's content and cost breakdown, summarize failures by error pattern
Reading the Help Center — search and read Coolhand's help center articles with HelpCenterDocs, no API key required
Frontend (Feedback Collection Widget): coolhand-js - Frontend feedback widget for collecting user feedback on AI outputs
Ruby: coolhand gem - Coolhand monitoring for Ruby applications
Node.js: coolhand-node package - Coolhand monitoring for Node.js applications
Questions? Create an issue
Contribute? Submit a pull request
Support? Visit coolhandlabs.com
Coolhand Labs builds observability and feedback tooling for AI-powered applications. Our platform helps teams monitor LLM usage, collect structured human feedback, and improve output quality over time — across every provider and framework.
Author/Maintainer: Michael Carroll
Both files in this release have provenance metadata.
Apache-2.0 View SPDX License List
ai analytics anthropic api claude gemini github-copilot google gpt llm monitoring openai
Development Status 3 - Alpha
Intended Audience Developers
License OSI Approved :: Apache Software License
Operating System OS Independent
Programming Language Python :: 3
Topic Internet :: WWW/HTTP
Scientific/Engineering :: Artificial Intelligence
Software Development :: Libraries :: Python Modules
Release files for coolhand 0.13.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
Built distribution (wheel)
Total release size: 385.7 kB
Release files / coolhand-0.13.0.tar.gz
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Release files / coolhand-0.13.0-py3-none-any.whl
Security for coolhand 0.13.0
Both files in this release have been uploaded with provenance metadata.
With provenance coolhand-0.13.0.tar.gz Nov 25, 2026
With provenance coolhand-0.13.0-py3-none-any.whl Nov 25, 2026
Attestation for coolhand-0.13.0.tar.gz
Attestation for coolhand-0.13.0-py3-none-any.whl
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.
Release history Release notifications | RSS feed
Nov 25, 2026 2 release files Full provenance
Nov 23, 2026 2 release files Full provenance
Nov 6, 2026 2 release files Full provenance
Oct 27, 2026 2 release files Full provenance
Oct 21, 2026 2 release files Full provenance
Oct 19, 2026 2 release files Full provenance
Oct 14, 2026 2 release files Full provenance
Sep 20, 2026 2 release files Full provenance
Sep 17, 2026 2 release files Full provenance
Sep 13, 2026 2 release files Full provenance
Sep 10, 2026 2 release files Full provenance
Jul 31, 2026 2 release files Full provenance
Jun 22, 2026 2 release files No provenance
Jun 3, 2026 2 release files No provenance
May 13, 2026 2 release files No provenance
Apr 29, 2026 2 release files No provenance
Jan 5, 2026 2 release files No provenance
Jan 2, 2026 2 release files No provenance
"PyPI", "Python Package Index", and the blocks logos are registered trademarks of the Python Software Foundation.
© 2026 Python Software Foundation




