slimchain
Local tracing hooks for LangChain and LangGraph. Stores traces locally or posts them to a webhook.
Install
pip install -e .
Enable tracing
Tracing is controlled by SLIMCHAIN_TRACING and an output directory:
SLIMCHAIN_TRACING=trueto enable recording.SLIMCHAIN_DIR=/path/to/outputto control where JSON is written (default:~/.slimchain).
Traces are written to:
traces.jsonl(append-only)traces.json(pretty JSON)
Webhook ingestion
To post traces to slimchain servers, set the webhook endpoint and project id:
SLIMCHAIN_ENDPOINT=https://your-serverSLIMCHAIN_PROJECT_ID=123SLIMCHAIN_API_KEY=your_project_api_key
When SLIMCHAIN_ENDPOINT and SLIMCHAIN_PROJECT_ID are set, traces are POSTed to:
POST {SLIMCHAIN_ENDPOINT}/traces/{SLIMCHAIN_PROJECT_ID}
.env support
If a .env file exists in the working directory, slimchain will load it on startup.
You can override the path with SLIMCHAIN_DOTENV=/path/to/.env.
LangChain integration
Attach the callback to any LangChain model or runnable:
from slimchain.client import Client
from slimchain.watcher import SlimchainCallback
client = Client(root=".slimchain")
client.config.tracing = True
callback = SlimchainCallback(client=client)
# Example with any LangChain chat model
model = SomeChatModel(
model="...",
callbacks=[callback],
)
response = model.invoke("Say hello in one sentence.")
LangGraph integration
Pass the callback via the LangGraph node or runnable config:
from slimchain.client import Client
from slimchain.watcher import SlimchainCallback
from langgraph.graph import END, StateGraph
client = Client(root=".slimchain")
client.config.tracing = True
callback = SlimchainCallback(client=client)
# inside a node function
message = model.invoke(prompt, config={"callbacks": [callback]})
Examples
Run the smoke examples after installing their dependencies:
pip install langchain-openai langchain-google-genai langgraph
Gemini:
SLIMCHAIN_TRACING=true \
GOOGLE_API_KEY=... \
.venv/bin/python examples/gemini_smoke.py
OpenRouter (OpenAI-compatible client):
SLIMCHAIN_TRACING=true \
OPENROUTER_API_KEY=... \
.venv/bin/python examples/openrouter_smoke.py
LangGraph (OpenRouter):
SLIMCHAIN_TRACING=true \
OPENROUTER_API_KEY=... \
.venv/bin/python examples/langgraph_smoke.py
Multi-agent (Gemini + OpenRouter):
SLIMCHAIN_TRACING=true \
GOOGLE_API_KEY=... \
OPENROUTER_API_KEY=... \
.venv/bin/python examples/multi_agent_smoke.py
Optional model overrides for the multi-agent example:
GEMINI_MODEL=gemini-3.1-flash-lite
OPENROUTER_MODEL=openai/gpt-4o-mini
Output schema
Each trace record includes:
trace_id,node_name,frameworkinput,outputtokens_in,tokens_outduration_ms,model_usedtimestamp,project,status,errormetadata
TEST
.venv/bin/python -m pytest -q
Metadata
Release files for slimchain 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| slimchain-0.1.1.tar.gz | 8.2 kB | Without provenance | Details for slimchain-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| slimchain-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for slimchain-0.1.1-py3-none-any.whl |
Total release size: 16.3 kB
Release files / slimchain-0.1.1.tar.gz
| Download URL | slimchain-0.1.1.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
30a3258442806eda0d54a86ddfe3d05951cc40c980ea038f91ba8f268f36a677
|
|
BLAKE2b-256 checksum How to use checksums |
0a5cace82edf5e2d7a744f9e1e193c21616015204707f10e285fc8c6eb3a51a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / slimchain-0.1.1-py3-none-any.whl
| Download URL | slimchain-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bba203cf9aebf7bc204fa0d48371fe876f24506c9573f69bca9330f7e1a86a70
|
|
BLAKE2b-256 checksum How to use checksums |
f60cef0efafb02f326f1cf89c7e20e53ff90f66c36dc69abdb7302d88cd76e38
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Security for slimchain 0.1.1
Provenance
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.