SDK Documentation

RANKIGI SDK
Quickstart

Add tamper-evident governance to your AI agents in under 5 minutes. The SDK is non-blocking — errors are always swallowed, ensuring observability never impacts your agent's critical path.

Prerequisites

1. Install

Add the RANKIGI SDK to your Node.js agent.

bashnpm install @rankigi/sdk

2. Initialize

Create a Rankigi instance with your API key and agent ID. Errors are swallowed — observability never crashes your agent.

typescriptimport { Rankigi } from "@rankigi/sdk"; const rankigi = new Rankigi({ apiKey: process.env.RANKIGI_API_KEY!, // from /dashboard/keys agentId: process.env.RANKIGI_AGENT_ID!, // from /dashboard/agents // baseUrl: "https://your-instance.com" — optional for self-hosted });

3. Track Tool Calls

Every tool invocation — inputs and outputs are SHA-256 hashed before leaving your environment.

typescript// Track every tool call your agent makes const result = await webSearchTool({ query: "Q4 revenue report" }); await rankigi.trackToolCall( "web_search", // tool name { query }, // input — hashed SHA-256 before sending result, // output — hashed SHA-256 before sending ); // With severity override (default: "info") await rankigi.trackToolCall("bash", command, output, { severity: "warn" });

4. Track Agent Output

Record the agent's final response or any intermediate outputs.

typescript// Track the agent's final response const response = await llm.invoke(messages); await rankigi.trackAgentOutput(response.content);

5. Track Errors

Surface errors into your RANKIGI compliance feed for root-cause analysis.

typescript// Track errors — never throws, always safe try { const result = await riskyOperation(); } catch (err) { await rankigi.trackError(err); throw err; // re-throw if needed — trackError won't interfere }

6. Custom Events

Log arbitrary governance events — agent handoffs, human interventions, or context snapshots.

typescript// Track any custom event with metadata await rankigi.trackCustomEvent("agent_handoff", { from_agent: "research-agent", to_agent: "writer-agent", context_size: tokens.length, });

REST API (any language)

Call the ingest endpoint directly from Python, Go, or any HTTP client. No SDK required.

bash# Test your setup with curl curl -s -X POST https://rankigi.com/api/ingest \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $RANKIGI_API_KEY" \ -d '{ "agent_id": "$RANKIGI_AGENT_ID", "action": "tool_call", "tool": "web_search", "severity": "info", "payload": { "query": "test query" } }' | jq

Full API Reference

All RANKIGI API routes accept a Authorization: Bearer <key> header. Events are deduplicated by SHA-256 hash, so it is safe to retry.

POST /api/ingestIngest a single event
GET /api/eventsList events for org
GET /api/agentsList agents for org
GET /api/alertsList compliance alerts
POST /api/reports/generateGenerate a compliance report
GET /api/reportsList generated reports