Skip to main content

rankigi-langchain

LangChain (Python) callback handler that adds RANKIGI cryptographic receipts to every LLM, tool, agent, retriever, and LangGraph node.

Compatible with langchain-core >= 0.1 and LangGraph.

Install

pip install rankigi-langchain

Setup

First, enroll a connector passport in your RANKIGI dashboard (Agents → New, type "connector"). Copy the credentials into your environment:

export RANKIGI_API_KEY=rnk_...
export RANKIGI_AGENT_ID=<uuid>
export RANKIGI_PASSPORT_ID=<uuid>
export RANKIGI_SIGNING_KEY=<base64 ed25519 seed>

Then attach the callback:

from rankigi_langchain import RankigiCallbackHandler
from langchain.agents import AgentExecutor

executor = AgentExecutor(
    agent=agent,
    tools=tools,
    callbacks=[RankigiCallbackHandler(agent_tag="checkout-service-prod")],
)

Or pass per-invocation via RunnableConfig:

executor.invoke(
    {"input": "..."},
    config={"callbacks": [RankigiCallbackHandler(agent_tag="checkout-service-prod")]},
)

LangGraph works the same way:

graph.invoke(
    state,
    config={"callbacks": [RankigiCallbackHandler(agent_tag="research-agent")]},
)

What gets a receipt

LangChain callback RANKIGI action
on_llm_end / on_chat_model_start+end llm_call
on_tool_end tool_call
on_agent_action agent_action
on_agent_finish agent_finish
on_chain_start/end (LangGraph nodes + top-level only) chain_start / chain_end
on_retriever_end retrieval
any on_*_error callback *_error with severity="warn"

What gets hashed

Prompts, completions, tool inputs, tool outputs, agent reasoning, retriever queries, and document contents are SHA-256-hashed locally by the SDK before any network call. Only the hashes plus safe metadata (model name, token counts, latency, run/parent IDs, LangGraph node names) reach RANKIGI.

Safety

Every callback is wrapped in try/except. SDK or network failures are absorbed silently — the callback never raises into LangChain. The underlying SDK has a durable disk queue that absorbs RANKIGI downtime and retries.

Explicit credentials

If you can't use env vars, pass the credentials directly:

RankigiCallbackHandler(
    api_key=os.environ["RANKIGI_API_KEY"],
    agent_id=os.environ["RANKIGI_AGENT_ID"],
    passport_id=os.environ["RANKIGI_PASSPORT_ID"],
    signing_private_key=os.environ["RANKIGI_SIGNING_KEY"],
    agent_tag="checkout-service-prod",
)

Test injection

For unit tests, pass a mock client:

class FakeClient:
    def track(self, **kwargs): ...

RankigiCallbackHandler(client=FakeClient())

License

MIT

Metadata

Release files for rankigi-langchain 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rankigi-langchain 1.0.0
File Size Uploaded
rankigi_langchain-1.0.0.tar.gz 18.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rankigi-langchain 1.0.0
File Interpreter ABI Platform
rankigi_langchain-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 24.4 kB

Release files / rankigi_langchain-1.0.0.tar.gz

Download URL rankigi_langchain-1.0.0.tar.gz
Size 18.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0fcdd028730fa5844de884642ff696283547cf76d0754ddc6dafe4e229a159ba
BLAKE2b-256 checksum
How to use checksums
94ce20d358383aeb7f319ed6f46d5858a249fc33f84fc275da0ce565b7f970aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / rankigi_langchain-1.0.0-py3-none-any.whl

Download URL rankigi_langchain-1.0.0-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1ff2994a0fabeea2df4f8e798e0e37b2923ee09f60a59194779d31cff6353b8b
BLAKE2b-256 checksum
How to use checksums
254cb8ff47d861e76847a2255fdb3a67a4f09186908930799cba45bd33a6d7a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page