Skip to content

feat(#71): token math per model - #72

Merged
ParallelEntrepreneur merged 1 commit into
mainfrom
feat/per-model-estimates
Oct 10, 2026
Merged

ParallelEntrepreneur merged 1 commit into
mainfrom
feat/per-model-estimates

Conversation

@ParallelEntrepreneur

Copy link
Copy Markdown
Contributor

Summary

Implements GitHub issue #71: Token math per model. Adds optional model_weights array to subscription records for plans whose quota costs depend on the model (e.g., GLM-5.3 vs GLM-5.3-Flash).

  • Schema: Add model_weights[], default_model, and estimates_by_model to subscriptions
  • Data: Populate Z.AI GLM plans with weights for GLM-5.3 and GLM-5.3-Flash from https://docs.z.ai/devpack/overview
  • Build: Compute per-model token and USD estimates using the STANDARD (agentic-coding-v1) profile
  • Validator: Enforce that every model in a weight is in models_included
  • Tests: Verify GLM-5.3's per-model estimate matches the current top-level estimate; Flash yields 3x more tokens at 1/3 the cost per token

Technical Details

Z.AI GLM-5.3-Flash multipliers (published)
Fetched from https://docs.z.ai/devpack/overview:

  • Input: 2.3
  • Cached Input: 0.56
  • Output: 8

Per-model estimates for zai/lite:

  • GLM-5.3: 114.6M tokens/month @ $0.1571/Mtok (default model)
  • GLM-5.3-Flash: 345.3M tokens/month @ $0.0521/Mtok (published, not implemented)

Build logic: For each model with weights, computes credits_per_call = ((input_tokens - cached) × input_multiplier + cached × cached_multiplier + output × output_multiplier) / 10000, then runs estimateForPlan with that conversion factor.

Skipped

API: The tokker-worker does not yet serve subscription data, so the new fields are not exposed via API at this time (per #71 scope).


Closes #71

🤖 Generated with Claude Code

…imates

Add optional model_weights array to subscriptions to enable per-model token math.
Implement schema changes, validator rules, and build logic to compute estimates_by_model.
For Z.AI GLM plans, populate weights for GLM-5.3 (6.9/1.7/24) and GLM-5.3-Flash (2.3/0.56/8)
from https://docs.z.ai/devpack/overview. Build computes per-model estimates showing Flash yields
3x more tokens/month at 1/3 the cost per token.

- Schema: Add model_weights[], default_model, estimates_by_model to subscriptions
- Validator: Enforce that every weight's model is in models_included
- Build: Compute estimates_by_model using STANDARD profile and per-model credit conversions
- Tests: Verify GLM-5.3 estimate matches top-level; Flash yields more tokens at lower cost
- API: Worker does not yet serve subscription data (skipped per #71 scope)

Co-authored-by: Colonizer Settlers <331648616+colonizer-settlers@users.noreply.github.com>
@ParallelEntrepreneur
ParallelEntrepreneur merged commit 50b73b5 into main Oct 10, 2026
3 checks passed
ParallelEntrepreneur added a commit that referenced this pull request Oct 10, 2026
…hness stamping

Resolve conflicts from rebasing #73 onto origin/main (#72 merge).
Integrated freshness stamping (annotate) into the build process while
preserving USD conversions, per-model estimates, and CSV exports.
Added argument validation for --as-of and unknown arguments.

Co-authored-by: Colonizer Settlers <331648616+colonizer-settlers@users.noreply.github.com>
ParallelEntrepreneur added a commit that referenced this pull request Oct 17, 2026
…e staleness check (#18) (#73)

* feat(data): freshness SLAs, stale flags in the build and a Worker-side staleness check (#18)

Refs #18

Co-Authored-By: Colonizer Settlers <331648616+colonizer-settlers@users.noreply.github.com>

* fix: rebase conflict resolution - merge build USD/estimates with freshness stamping

Resolve conflicts from rebasing #73 onto origin/main (#72 merge).
Integrated freshness stamping (annotate) into the build process while
preserving USD conversions, per-model estimates, and CSV exports.
Added argument validation for --as-of and unknown arguments.

Co-authored-by: Colonizer Settlers <331648616+colonizer-settlers@users.noreply.github.com>

---------

Co-authored-by: Colonizer Settlers <331648616+colonizer-settlers@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Token math per model: plans whose quota cost depends on the model (GLM-5.3 vs GLM-5.3-flash, Opus vs Sonnet, Copilot premium multipliers)

1 participant