openrouter-audit-logging
Installation
SKILL.md
OpenRouter Audit Logging
Overview
Every OpenRouter API call returns a generation ID and metadata that enables comprehensive audit logging. The generation endpoint (GET /api/v1/generation?id=) provides exact cost, token counts, provider used, and latency -- data that the initial response doesn't always include. This skill covers structured logging, cost tracking, PII redaction, and compliance-ready audit trails.
Prerequisites
- An OpenRouter API key (
sk-or-v1-...) exported asOPENROUTER_API_KEY— see theopenrouter-install-authskill for setup - Python 3.8+ with the OpenAI SDK and
requests(pip install openai requests) — the audit wrapper fetches exact cost from the generation endpoint withrequests - SQLite: the Python stdlib
sqlite3module writes the audit table; thesqlite3CLI runs the Audit Queries againstopenrouter_audit.db - Optional: a SIEM destination (Splunk, Datadog, ELK) if you ship the structured JSON log lines downstream