# lockn-logger > Automatically captures LLM API call usage from OpenClaw sessions and logs them to LockN Logger for cost tracking and attribution. - Author: LockN-AI - Repository: LockN-AI/lockn-logger - Version: 20260205185742 - Stars: 0 - Forks: 0 - Last Updated: 2026-02-06 - Source: https://github.com/LockN-AI/lockn-logger - Web: https://mule.run/skillshub/@@LockN-AI/lockn-logger~lockn-logger:20260205185742 --- # LockN Logger Skill Automatically captures LLM API call usage from OpenClaw sessions and logs them to LockN Logger for cost tracking and attribution. ## Description This skill monitors OpenClaw session transcripts and extracts LLM usage data (tokens, costs, model info) to post to a LockN Logger instance. Enables zero-friction cost tracking across all agents. ## Usage The skill runs automatically via cron or can be triggered manually. It scans session transcripts for messages with `usage` data and posts receipts to the configured LockN Logger endpoint. ### Manual Run ```bash node /path/to/skills/lockn-logger/capture.js ``` ### Cron Integration Add to HEARTBEAT.md or configure a cron job to run periodically. ## Configuration Set these environment variables or configure in OpenClaw config: | Variable | Default | Description | |----------|---------|-------------| | `LOCKN_LOGGER_ENDPOINT` | `http://localhost:8080/api/receipts` | LockN Logger API URL | | `LOCKN_LOGGER_API_KEY` | (none) | Optional API key for auth | | `LOCKN_LOGGER_BATCH_SIZE` | `10` | Receipts per batch POST | | `LOCKN_LOGGER_INCLUDE_LOCAL` | `true` | Include local models (cost=$0) | ## What Gets Captured From each OpenClaw message with usage data: - **model**: Model identifier (e.g., `claude-opus-4-5`) - **provider**: Provider name (e.g., `anthropic`, `llamacpp-qwen`) - **inputTokens**: Input token count - **outputTokens**: Output token count - **totalCost**: Calculated cost in USD - **timestamp**: When the call was made - **correlationId**: Session ID for attribution - **agentId**: Agent identifier from session key ## Deduplication The skill tracks the last processed timestamp per session to avoid duplicate receipts. State is stored in `state/last-scan.json`. ## Error Handling - Network failures: Logged and skipped (non-blocking) - Invalid receipts: Logged with details, skipped - Rate limiting: Exponential backoff (max 3 retries) ## Triggers - `log llm usage`, `capture receipts`, `sync to lockn logger`