mirrorkit is a lightweight, drop-in production trace collector for LLM agents. Add two lines to your existing LangChain / LangGraph / Anthropic / OpenAI script and your agent’s traces start streaming to Mirrors — non-blocking, background-batched, with negligible latency.
Install
Usage (2 lines)
MIRROR_ENDPOINT environment variable, then to the production URL.
Options
Manual logging
For frameworks that aren’t auto-instrumented, enqueue a trace yourself. Messages are OpenAI-style chat dicts:LangChain global handler
init() registers a global LangChain callback handler automatically, so you don’t need to pass callbacks. If your setup doesn’t honor the global hook, pass the handler explicitly:
API
| Function | Description |
|---|---|
mirrorkit.init(api_key, project="default", endpoint=None, *, flush_interval=2.0, max_batch=50, instrument=True) | Start the collector. |
mirrorkit.log_trace(messages, *, trace_id=None, model=None) | Manually enqueue one trace. |
mirrorkit.flush(timeout=5.0) | Block until the queue drains. |
mirrorkit.shutdown() | Stop the collector. |
mirrorkit.handler() | LangChain callback handler for manual registration. |
Failures (non-2xx / network errors) are retried a couple of times, then dropped — the collector never raises into your program. The wire format is documented in the collect API reference.
mirrors CLI — install it with pip install "mirrorkit[cli]".