Skip to content

Feature: Add offline mode to skip pricing fetch and only show token counts #374

@bluesky8318

Description

@bluesky8318

Problem

When running tokscale models --json (or any report command) without network access, the CLI fails entirely because it cannot fetch pricing data from LiteLLM:

[tokscale] LiteLLM network error (attempt 1/3): error sending request for url (https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json)
[tokscale] LiteLLM JSON parse failed: error decoding response body
Error: error decoding response body

This makes tokscale unusable in offline environments, behind strict corporate firewalls, or during temporary network outages.

Proposal

Add an --offline flag (or --no-pricing) that:

  1. Skips fetching pricing data from LiteLLM / OpenRouter entirely
  2. Still reads and parses local session files normally
  3. Reports token counts (input, output, cache read/write, reasoning) and message counts as usual
  4. Omits cost columns or shows them as N/A / $0

Example usage

# Offline mode — token stats only, no network requests
tokscale models --json --offline

# Works with all existing filters
tokscale models --json --offline --today --claude
tokscale --offline --since 2026-03-01 --until 2026-03-31

Expected output

Token counts and message counts are the primary data — they come from local session files and don't require any network access. Cost calculation is a nice-to-have enhancement that depends on external pricing data. The CLI should not fail to show the core data when the enhancement is unavailable.

Workaround

Currently the only workaround is to have a valid pricing cache file at ~/.cache/tokscale/pricing-litellm.json from a previous successful run, but this is fragile and not always available.

Environment

  • tokscale v2.0.0
  • macOS Darwin 25.4.0
  • Node.js v24.14.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions