mirror of
https://gh-proxy.org/https://github.com/klinsmaya/new-api.git
synced 2026-11-10 02:17:24 +08:00
Add tier(name, fixed(usd)) pricing leaves to conditional token expressions, with static validation, token/request billing metadata, and safe settlement when successful requests have missing or zero token usage. Preserve group and request multipliers, separate tool charges, and explicit zero prices. Reject fixed expressions on unsupported Realtime and task-usage entrances. Expose per-token and per-call tier editing, preserve both drafts, and show request units consistently in pricing summaries and consume logs. Retain matched-branch metadata and update all seven frontend locales. Validation passed: - go test ./pkg/billingexpr ./relay/helper ./service ./setting/billing_setting ./relay -count=1 - Frontend pricing, model-pricing, editor and usage-log regression suites - Typecheck, scoped lint, protected-header formatting, i18n validation and build - go test ./service -run TestFixedPriceBillingDatabaseMatrix -count=1 -v with TEST_FIXED_MYSQL_DSN and TEST_FIXED_POSTGRES_DSN set to isolated local test databases: SQLite 3.50.4, MySQL 8.0.46, PostgreSQL 16.15. All 39 database cases passed, including reserve/settle/refund, zero price, missing usage, branch changes and insufficient-quota handling. No production database schema or migration changes.