openrouter-audit-logging
Skill by jeremylongshore
Adds audit logging to OpenRouter API calls in Python. It records exact cost, token counts, latency and model use in an append-only SQLite table, for developers building compliance trails or tracking usage.
Install openrouter-audit-logging
Built from the published package, never by AI.
git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace /tmp/tons-of-skills-marketplace && mkdir -p ~/.claude/skills && cp -r /tmp/tons-of-skills-marketplace/skills/.curated/openrouter-audit-logging ~/.claude/skills/openrouter-audit-loggingRun in your terminal. Claude Code loads skills from ~/.claude/skills automatically.
Step-by-step: install openrouter-audit-logging in Claude Code
git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace /tmp/tons-of-skills-marketplace && mkdir -p ~/.gemini/antigravity-cli/skills && cp -r /tmp/tons-of-skills-marketplace/skills/.curated/openrouter-audit-logging ~/.gemini/antigravity-cli/skills/openrouter-audit-loggingAntigravity CLI loads skills from ~/.gemini/antigravity-cli/skills, or .agents/skills for one project.
Step-by-step: install openrouter-audit-logging in Antigravity CLI
Skills can run scripts on your machine. Some need an API key: check the README.
About
This skill adds audit logging to OpenRouter API calls. After each chat completion, a wrapper hashes the prompt with SHA-256, times the call, and fetches exact cost and token data from the OpenRouter generation endpoint. Each request becomes a structured audit entry saved in an append-only SQLite table, indexed on timestamp and user ID.
The skill also scrubs emails, phone numbers, SSNs, card numbers and OpenRouter keys before logging, and stores only prompt hashes, not raw prompts. It includes SQL queries for daily cost by model, 24-hour error rates and top spenders by user ID. It is aimed at developers who need compliance trails, want to debug production issues, or want to track model usage.
Written from the project's SKILL.md and checked against it.
What it can do
- audited_completionMakes a chat completion and returns an audit entry with cost and latency.
- Generation metadata retrievalFetches exact cost and token counts from the OpenRouter generation endpoint.
- init_audit_db and write_auditCreates an append-only SQLite audit table and writes entries without duplicate generation IDs.
- redact_piiScrubs emails, phones, SSNs, card numbers and API keys before logging.
- Audit queriesProvides SQL for daily cost by model, error rate and top spenders.
- Error handling guidanceLists fixes for generation 404s, duplicate IDs, missing total_cost and 401 errors.
What you need
- OpenRouter API key exported as OPENROUTER_API_KEY
- Python 3.8 or later
- openai and requests Python packages
- SQLite (Python sqlite3 module)
- Optional SIEM such as Splunk, Datadog or ELK
Try asking
- Set up audit logging for my OpenRouter calls using SQLite.
- Show me daily OpenRouter cost by model from my audit table.
- Redact emails and phone numbers from prompts before I log them.
Good to know
- Generation lookups can return 404 if fetched too long after the request; the source says to fetch within 30 minutes.
- total_cost may be missing while a generation is still processing.
- Raw prompts are not stored, only a 16-character SHA-256 hash.
Security check
B- Allowed to use Write, Edit without limitsIn
SKILL.md
Checked automatically: skills/.curated/openrouter-audit-logging/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work
Inside the skill
Allowed tools: ReadWriteEditGrepBash(python3:*)Bash(sqlite3:*)
Alternatives to openrouter-audit-logging
All alternatives →Runs a 7-stage workflow for auditing, cleaning up and reviewing GitHub repositories, plus competitor analysis. Written for developers who want a repo checked for secrets, junk files and documentation gaps.
Teaches an AI assistant to build, debug and explain Gradio web UIs and ML demos in Python. It covers the core API, components, event listeners, layouts and the MCP server option. Aimed at Python developers who work with Gradio.
Recommends menus, buttons, toolbars and disclosure controls for Apple platforms using Human Interface Guidelines conventions. Built for developers and designers making iOS, iPadOS, macOS or visionOS interfaces. Checks existing project design context before asking questions.
Creates production-ready FastAPI project structures with async patterns, dependency injection, and error handling. It is for developers starting new FastAPI applications or backend API projects.
Analyzes Android apps to find user workflows to expose as AppFunctions, so AI agents and system shortcuts can run them without opening the app UI. Generates Kotlin code and refines KDoc for Android developers.
Creates, edits, validates and runs Agent QA tests, suites and hooks through MCP or CLI. It keeps canonical IDs and schema contracts intact, for developers and QA teams using Agent QA.
Compare with openclaw-github-repo-commander, gradio or hig-components-menus
openrouter-audit-logging: common questions
Does it store raw prompts?
No. The skill stores only a 16-character SHA-256 hash of each prompt, and says raw prompts are never stored.
Where is the audit data kept?
By default it is written to an SQLite file named openrouter_audit.db. The source also suggests S3 or centralized logging for hardened storage.
Why might a generation lookup fail?
The generation endpoint returns 404 if the ID is not found or the request is too old. The source advises fetching within 30 minutes.
How do I install openrouter-audit-logging?
Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.
Is openrouter-audit-logging free?
The code is published under the MIT licence. The service it connects to may have its own pricing.
Is openrouter-audit-logging safe to use?
It scores 76 of 100. Grades: maintenance A, licence A, quality A. Security check: grade B (allowed to use write, edit without limits). Review the code before you install. How grades work.
What are alternatives to openrouter-audit-logging?
Similar skills: openclaw-github-repo-commander, gradio, hig-components-menus, fastapi-templates.
