Skip to main content

copilot-tokens

Token usage tracker for VS Code Copilot Chat. A zero-dependency Python CLI that reads the local Copilot Chat debug logs and totals up input / output tokens, model, and latency per request and per session.

Pure standard library. No dependencies. Python 3.9+.

Why this exists

  • Since VS Code 1.13x, empty-window chat sessions write their debug logs to globalStorage/github.copilot-chat/debug-logs/. Several third-party tracker extensions only scan the older workspaceStorage path, so they end up showing "no sessions found".
  • BYOK (bring-your-own-key) users don't see usage on the GitHub billing page, so reading the local logs is the only option.
  • This tool reads llm_request events straight from the logs and does not rely on any VS Code internal API.

Prerequisite

Enable debug log file writing in VS Code settings:

"github.copilot.chat.agentDebugLog.fileLogging.enabled": true

With this on, the full request logs for every session are written to local disk. Turn it off if you don't want logs persisted (the tool will then have nothing to read).

Install

pip install copilot-tokens

Or run it without installing:

pipx run copilot-tokens

Usage

copilot-tokens                          # sessions from the last 7 days
copilot-tokens --days 30                # last 30 days
copilot-tokens --all                    # all sessions
copilot-tokens --top 5                  # top 5 sessions by total tokens
copilot-tokens --session 6ec414c0       # per-request detail (prefix match)
copilot-tokens --json                   # JSON output
copilot-tokens --json --out usage.json  # export UTF-8 JSON file
copilot-tokens --root /path/to/User     # non-standard VS Code "User" dir
copilot-tokens --version                # print version

Sample output

Session    Time            Reqs       Input     Output    Cached     Total  Model / Title
──────────────────────────────────────────────────────────────────────────────────────────
6ec414c0 09-18 19:07     37      2.9M      60k        0      3.0M  qwen3.8-27b×37  Help me write a script…
a8ba8abd 09-18 18:34      1     9,360      157        0     9,517  qwen3.8-27b  Who are you
──────────────────────────────────────────────────────────────────────────────────────────
Total                      38      2.9M      60k        0      3.0M  2 sessions

Detail view (--session <id>):

Session a8ba8abd-…
  Versions: VS Code 1.138.0 / Copilot 0.66.0
  Time:     09-18 17:49 → 09-18 18:34
  Title:    Who are you

  #  Time             Dur        Input    Output   Cached  Model
──────────────────────────────────────────────────────────────
  1  09-18 18:13     5.6s     9,360     157        0  qwen3.8-27b
──────────────────────────────────────────────────────────────
                              9,360     157        0  Total

Data sources

Both layouts are auto-discovered (new and legacy):

Layout Path
New (VS Code 1.13x+, includes empty-window sessions) %APPDATA%/Code/User/globalStorage/github.copilot-chat/debug-logs/<sid>/main.jsonl (Windows)
~/Library/Application Support/Code/User/globalStorage/… (macOS)
~/.config/Code/User/globalStorage/… (Linux)
Legacy (per workspace) %APPDATA%/Code/User/workspaceStorage/<hash>/GitHub.copilot-chat/debug-logs/<sid>/main.jsonl

Event types parsed (main.jsonl is JSONL, one event per line):

Event Used for
llm_request attrs.inputTokens / attrs.outputTokens / attrs.model / attrs.ttft; top-level ts (epoch ms) / dur (ms)
user_message first message becomes the session title
session_start VS Code / Copilot version info

Known limitations

  • Cached tokens are not recorded. VS Code currently does not write cache read/write tokens to the log (see microsoft/vscode#329657). The parser reserves a cachedTokens field; it will light up automatically once the format supports it.
  • Input tokens are the full context of each request (system prompt, history, tool results), so multi-turn sessions show a large "input" total. This is normal context accumulation, not double counting.
  • The log format is an internal VS Code implementation with no stability guarantee. If data goes missing after a VS Code upgrade, please open an issue with one llm_request event from your main.jsonl (redacted).

Privacy

  • The tool is read-only over local log files. It never phones home or uploads anything.
  • Session titles come from your first user message. Review exported JSON for sensitive content before sharing.
  • Never commit raw main.jsonl logs to any repository.

VS Code extension

There is also a native VS Code extension with a themed webview panel, status bar total, daily usage chart, and CSV / JSON export. Install it from the Marketplace.

Extension preview

License

MIT

Metadata

Release files for copilot-tokens 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for copilot-tokens 0.2.2
File Size Uploaded Provenance Actions
copilot_tokens-0.2.2.tar.gz 18.0 kB With provenance Details for copilot_tokens-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for copilot-tokens 0.2.2
File Interpreter ABI Platform Actions
copilot_tokens-0.2.2-py3-none-any.whl Python 3 none any Details for copilot_tokens-0.2.2-py3-none-any.whl

Total release size: 28.5 kB

Release files / copilot_tokens-0.2.2.tar.gz

Download URL copilot_tokens-0.2.2.tar.gz
Size 18.0 kB
Tags Source
SHA-256 checksum
How to use checksums
6c6e4f5c4a24cfac476c24b8a6bdbcb04097542baf5a8c6721739a1bf8bf7a04
BLAKE2b-256 checksum
How to use checksums
793619ed61fe146cc4b8bab9d6fad6b9bf0a143d180216d06cf4a5cd97a39f51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 5, 2026.

Transparency log

Release files / copilot_tokens-0.2.2-py3-none-any.whl

Download URL copilot_tokens-0.2.2-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
57ddc7cad5fa43939d6dc16ae0e7ca6081daf1a92194b27d9aaedce410891c3b
BLAKE2b-256 checksum
How to use checksums
cded52166a1f7d673a784550e811ec7c7946cb3f320aa426ebf36421e9067035
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 5, 2026.

Transparency log

Security for copilot-tokens 0.2.2

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.

Select from 2 files

Attestation for copilot_tokens-0.2.2.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 Nov 5, 2026.

Transparency log

A 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.

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page