No description
Find a file
2026-04-23 22:18:50 +00:00
.github/workflows feat: 新增重建脚本 2026-02-25 14:03:41 +08:00
scripts feat: auto-fill missing cache_creation_input_token_cost_above_1hr for Claude models 2026-02-25 15:21:18 +08:00
.gitignore feat: add model pricing sync system 2026-02-25 11:28:11 +08:00
config.json chore: add gpt-5.4-mini 2026-03-20 13:51:47 +08:00
LICENSE Initial commit 2026-02-25 10:27:29 +08:00
model_prices_and_context_window.json chore: sync model pricing (1252f0e3) 2026-04-23 22:18:50 +00:00
model_prices_and_context_window.sha256 chore: sync model pricing (1252f0e3) 2026-04-23 22:18:50 +00:00
README.md feat: add model pricing sync system 2026-02-25 11:28:11 +08:00
rebuild.sh feat: 新增重建脚本 2026-02-25 14:03:41 +08:00

model-price-repo

Filtered model pricing data for CRS and sub2api projects. Syncs from the upstream litellm pricing file on a schedule, applying configurable prefix filters to keep only the models you actually use.

How it works

A GitHub Actions workflow runs every 10 minutes (and on manual trigger):

  1. Downloads the full model_prices_and_context_window.json from litellm
  2. Filters models by the prefix rules in config.json
  3. Merges new models into the existing output (additive — never removes)
  4. Applies alias mappings and custom model definitions
  5. Writes the output JSON + SHA-256 hash, commits only if content changed

Configuration

All settings live in config.json:

Field Description
upstream_url URL to the upstream litellm pricing JSON
output_file Output filename (default: model_prices_and_context_window.json)
hash_file SHA-256 hash filename for change detection
sync_mode "additive" (only add new) or "full" (replace each run)
update_existing Whether to update pricing data for models already in the output
prefix_filters List of prefixes — a model key must start with one to be included
exclude_patterns Substring patterns to exclude (applied before prefix matching)
aliases Map alias model keys to existing source models (deep copy pricing)
custom_models Manually defined pricing objects, always injected

Adding new model prefixes

Edit the prefix_filters array in config.json:

{
  "prefix_filters": [
    "claude-",
    "gpt-",
    "your-new-prefix/"
  ]
}

Adding aliases

Aliases create copies of an existing model's pricing under a new key:

{
  "aliases": {
    "claude-opus-4-6-thinking": {
      "source": "claude-opus-4-6",
      "description": "Thinking variant, same pricing"
    }
  }
}

If the source model doesn't exist in the filtered data, the alias is skipped with a warning.

Running locally

python3 scripts/sync_prices.py --config config.json --repo-root .

No pip dependencies — uses Python standard library only.

CRS integration

Point CRS to the raw output file from this repo:

MODEL_PRICES_URL=https://raw.githubusercontent.com/<owner>/model-price-repo/main/model_prices_and_context_window.json

The output JSON structure is identical to what litellm produces (model key -> pricing object), so CRS pricingService.js works without changes.

License

MIT