token-cost-computation

Calculate token usage totals and estimated costs from Codex CLI and Claude Code SSE JSONL logs.

2|Updated Jan 30, 2026
One-click install
npx skills add https://github.com/tankygranny05/agent-box --skill token-cost-computation
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: token-cost-computation
Source: https://github.com/tankygranny05/agent-box/tree/main/agent-box/seed/codex-skills/token-cost-computation
Command: npx skills add https://github.com/tankygranny05/agent-box --skill token-cost-computation

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill helps you understand and estimate the costs associated with using AI models by computing token usage from log files.

Core Features & Use Cases

  • Token Usage Calculation: Aggregates input and output tokens for both Codex (OpenAI) and Claude (Anthropic) models.
  • Cost Estimation: Calculates estimated API costs based on fetched or pinned pricing data.
  • Use Case: Analyze your monthly AI spending by feeding your SSE JSONL logs into this skill to get a detailed breakdown of token consumption and associated costs for different models.

Quick Start

Run the compute_token_costs.py script with paths to your Codex and Claude SSE logs.

Frequently Asked Questions about token-cost-computation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I calculate token costs from SSE JSONL logs?

You calculate token costs by parsing SSE JSONL event data to aggregate input and output token metrics, then applying pricing models to estimate API billing for Codex and Claude models.

What is the best way to estimate API usage costs for Claude and Codex models?

Estimate API usage costs by processing SSE JSONL logs with a script that aggregates token consumption and applies fetched or pinned pricing data to generate a detailed billing breakdown.

Can I analyze token consumption breakdowns for both OpenAI and Anthropic models?

Yes, you can analyze token consumption breakdowns for both OpenAI and Anthropic models by feeding Codex CLI and Claude Code SSE JSONL logs into the cost computation script.

How do I parse SSE JSONL event data for token metrics?

Parse SSE JSONL event data for token metrics by running a Python script that reads the log streams, extracts token usage totals, and computes estimated costs based on pricing data.

Do I need pinned pricing data to compute accurate API billing estimates?

You do not strictly need pinned pricing data to compute API billing estimates; the cost calculation supports both fetched pricing data and pinned rates for flexibility.

What limitations exist when calculating token usage from Codex and Claude logs?

A limitation when calculating token usage is that the skill requires properly formatted SSE JSONL logs from Codex CLI and Claude Code streams to accurately parse token metrics and estimate costs.