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
Metadata
Release files for rankigi-litellm 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| rankigi_litellm-1.0.0.tar.gz | 23.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rankigi_litellm-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 29.4 kB
Release files / rankigi_litellm-1.0.0.tar.gz
| Download URL | rankigi_litellm-1.0.0.tar.gz |
|---|---|
| Size | 23.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
077dd3d35f45e9114a533edf9bcfc022b7f27097990a9294b0cca0c3eef55897
|
|
BLAKE2b-256 checksum How to use checksums |
9b0bb24f1f10c674e51b3396930742bb920cfa0b5bf49f48b2030ee859604b9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / rankigi_litellm-1.0.0-py3-none-any.whl
| Download URL | rankigi_litellm-1.0.0-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4de1d72325afd6760cf5233e8d78ca0e3e59c18946a390c5965b36d178012ad7
|
|
BLAKE2b-256 checksum How to use checksums |
fb47b953925e87d66a4289b04bb9768b075f5315d208a4837a010d6fe1da50ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|