LiteLLM CustomLogger that adds RANKIGI cryptographic receipts to every model call routed through LiteLLM.
Project description
rankigi-litellm
RANKIGI integration for LiteLLM. Every model call routed through LiteLLM gets a cryptographic receipt.
Works with direct litellm.completion() usage and with the LiteLLM
proxy (config.yaml).
Install
pip install rankigi-litellm
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>
Direct litellm usage
import litellm
from rankigi_litellm import RankigiLogger
litellm.callbacks = [RankigiLogger(agent_tag="checkout-service-prod")]
response = litellm.completion(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "hi"}],
)
Every litellm.completion(...) call now writes a receipt to the RANKIGI
chain identified by the connector passport.
LiteLLM proxy
In config.yaml:
litellm_settings:
callbacks: ["rankigi_litellm.RankigiLogger"]
The proxy will instantiate the logger and credentials will be picked up
from RANKIGI_* env vars.
What gets a receipt
| LiteLLM event | RANKIGI action |
|---|---|
async_log_success_event / log_success_event |
llm.<provider>.chat |
async_log_stream_event (on stream completion) |
same, with meta.stream = true |
async_log_failure_event / log_failure_event |
llm_error (severity: "warn") |
What gets hashed
messages (the full prompt history) and response (the model output) are
SHA-256-hashed locally by the SDK before any network call. Only the
hashes plus safe metadata reach RANKIGI:
model_id(gen_ai.request.modelequivalent)provider_request_id(provider completion ID)provider,call_type(completion,acompletion, etc.)token_usage(full StandardLoggingPayload usage block)latency_msagent_metafromagent_tag
Safety
- Every callback is wrapped in try/except. SDK or network failures are absorbed silently. The logger never raises into LiteLLM.
- Logging callbacks are post-hoc (after the model call), so they cannot affect the response your application sees.
- We do not implement
async_pre_call_hook. That hook can raise and block LiteLLM's request — incompatible with the RANKIGI non-blocking principle. The proof layer must never interfere with the agent it observes.
Explicit credentials
If you can't use env vars, pass the credentials directly:
RankigiLogger(
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): ...
RankigiLogger(client=FakeClient())
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rankigi_litellm-1.0.0.tar.gz.
File metadata
- Download URL: rankigi_litellm-1.0.0.tar.gz
- Upload date:
- Size: 23.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
077dd3d35f45e9114a533edf9bcfc022b7f27097990a9294b0cca0c3eef55897
|
|
| MD5 |
5ccd3f94de6c07bbb63ae3b4b7d8eff9
|
|
| BLAKE2b-256 |
9b0bb24f1f10c674e51b3396930742bb920cfa0b5bf49f48b2030ee859604b9f
|
File details
Details for the file rankigi_litellm-1.0.0-py3-none-any.whl.
File metadata
- Download URL: rankigi_litellm-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4de1d72325afd6760cf5233e8d78ca0e3e59c18946a390c5965b36d178012ad7
|
|
| MD5 |
7e974b0f28a23968fe00bc8e160717ca
|
|
| BLAKE2b-256 |
fb47b953925e87d66a4289b04bb9768b075f5315d208a4837a010d6fe1da50ea
|