opencode-costs
Leer en español
Cost reporter for OpenCode — detailed cost breakdown per agent and sub-agent.
OpenCode's TUI only shows the main agent's cost. This tool reveals the full picture: main agent + all sub-agents with their individual costs, tokens, and models.
Why?
When you use OpenCode with SDD orchestrators or delegated tasks, the real cost is hidden. A session might show $0.50 but the sub-agents actually spent $5.00. opencode-costs shows you the truth.
Installation
# From GitHub
pip install git+https://github.com/caertos/opencode-costs.git
# Or clone and install
git clone https://github.com/caertos/opencode-costs.git
cd opencode-costs
pip install .
Usage inside OpenCode
This is the primary use case. Inside OpenCode, press ! to run terminal commands:
!costs
That's it. You'll see the full cost breakdown of the current session including all sub-agents.
Auto-detection: When running inside OpenCode, the tool automatically detects your current session by matching the working directory. No need to pass session IDs manually.
Quick reference
| Command | What it does |
|---|---|
!costs |
Cost breakdown of the current session |
!costs --all |
Global statistics across all sessions |
!costs --last 5 |
Last 5 sessions summary |
!costs --session ID |
Specific session by ID |
!costs --agent sdd-apply |
Filter by agent name |
!costs --json |
JSON output for piping |
Usage outside OpenCode
From a regular terminal:
# Most recent session
costs
# Last 10 sessions
costs --last 10
# Global stats
costs --all
# JSON for further processing
costs --json | jq '.summary.total_cost'
Example output
╭──────────────────────────────────────────────────────────────────────╮
│ COST REPORT ses_abc123 My session title │
╰──────────────────────────────────────────────────────────────────────╯
╭─────────────────────────────── RESUMEN TOTAL ────────────────────────╮
│ Cost Total $2.52 │
│ Tokens Input 574.9K │
│ Tokens Output 16.2K │
│ Reasoning 6.1K │
│ Duration 31m 38s │
╰──────────────────────────────────────────────────────────────────────╯
DESGLOSE POR AGENTE
╭───────────────────────────┬──────────┬──────────────┬────────╮
│ Agente │ Sesiones │ Costo │ % │
├───────────────────────────┼──────────┼──────────────┼────────┤
│ sdd-orchestrator-copilot │ 1 │ $0.98 │ 38.8% │
│ sdd-explore-copilot │ 2 │ $1.00 │ 39.6% │
│ sdd-apply-copilot │ 1 │ $0.54 │ 21.6% │
├───────────────────────────┼──────────┼──────────────┼────────┤
│ TOTAL │ 4 │ $2.52 │ 100% │
╰───────────────────────────┴──────────┴──────────────┴────────╯
How it works
Reads directly from OpenCode's SQLite database at ~/.local/share/opencode/opencode.db. No API keys, no external services, no tracking.
Requirements
- Python 3.10+
rich(installed automatically)
License
MIT
Metadata
Release files for opencode-costs 1.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| opencode_costs-1.0.6.tar.gz | 10.9 kB | With provenance | Details for opencode_costs-1.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| opencode_costs-1.0.6-py3-none-any.whl | Python 3 | none | any | Details for opencode_costs-1.0.6-py3-none-any.whl |
Total release size: 22.1 kB
Release files / opencode_costs-1.0.6.tar.gz
| Download URL | opencode_costs-1.0.6.tar.gz |
|---|---|
| Size | 10.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9d6750a104cbe9decbbb817c709bfefdb6d27be56a3d82a88821599f48265fc2
|
|
BLAKE2b-256 checksum How to use checksums |
bc037ba7993cfe4685bdb58b3e14fed24259eed831b3d9b5b183819110c7e2cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 4, 2026.
Transparency logRelease files / opencode_costs-1.0.6-py3-none-any.whl
| Download URL | opencode_costs-1.0.6-py3-none-any.whl |
|---|---|
| Size | 11.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2a02bbfedc59b34577ed2ca06fa6894582451dd9f13bdb680fdfffb27c7a4cf0
|
|
BLAKE2b-256 checksum How to use checksums |
2b7425cb284223e9a363ba619e14e054f3f7d18d9db780851ab883902b95ea31
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 4, 2026.
Transparency logSecurity for opencode-costs 1.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for opencode_costs-1.0.6.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 4, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.