The current pricing system mixes two responsibilities in one structure:
PricingConfig.table[].price through relay pricing lookup, freezes it into PricingDecision, and later uses that decision for pre-consumption and final settlement.PricingConfig.table[].price to render model price summaries and matrix details.Some video providers need a user-facing estimate such as 768p-6s, price per second, while the actual charge is settled by token usage, provider-returned deduction, or another backend billing result. Reusing PricingConfig for this would make display-only prices affect real billing.
Add a display-only pricing configuration that lets the frontend show a supplier-style price table for user estimation.
This configuration must:
ModelPricingRules; real matrix pricing remains unchanged.Add a new option key, separate from ModelPricingRules:
ModelDisplayPricing
The option value is a JSON map keyed by model name:
{
"kling-video": [
{
"specification": "768p-6s",
"official_supplier_tip": "Text-to-video and image-to-video, 768P 6s",
"price": 0.33333,
"unit": "second",
"sort_order": 1,
"discount_rate": 1
},
{
"specification": "768p-10s",
"official_supplier_tip": "Text-to-video and image-to-video, 768P 10s",
"price": 0.4,
"unit": "second",
"sort_order": 2,
"discount_rate": 1
},
{
"specification": "1080p",
"official_supplier_tip": "Text-to-video and image-to-video, 1080P",
"price": 0.58333,
"unit": "second",
"sort_order": 3,
"discount_rate": 1
}
]
}
Suggested Go type:
type ModelDisplayPricingItem struct {
Specification string `json:"specification"`
OfficialSupplierTip string `json:"official_supplier_tip"`
Price float64 `json:"price"`
Unit string `json:"unit"`
SortOrder int `json:"sort_order"`
DiscountRate float64 `json:"discount_rate"`
}
Field semantics:
specification: short SKU label shown in compact and detail views.official_supplier_tip: supplier-facing explanation shown in detail view.price: USD base display price before discount. This is not quota and not billing input.unit: display unit, such as second, call, image, or video.sort_order: stable ordering for the frontend and API response.discount_rate: display-only multiplier. 0 or omitted means no discount and is normalized to 1.Validation rules:
specification must not be empty.price must be greater than or equal to 0.unit must not be empty.discount_rate is normalized before validation: 0 or omitted becomes 1; after normalization, the accepted range is 0 < discount_rate <= 1.sort_order, then specification.Add a new ratio setting module, parallel to model_pricing.go, for display pricing only:
GetModelDisplayPricing(model string) []types.ModelDisplayPricingItemGetModelDisplayPricingCopy() map[string][]types.ModelDisplayPricingItemSetModelDisplayPricing(model string, items []types.ModelDisplayPricingItem) errorDeleteModelDisplayPricing(model string) errorUpdateModelDisplayPricingByJSONString(jsonStr string) errorModelDisplayPricing2JSONString() stringStore the JSON in options, matching the existing config pattern and avoiding a cross-database migration for a display-only setting.
The option lifecycle must follow the existing ModelPricingRules pattern:
ModelDisplayPricing to model.InitOptionMap() with an empty JSON object default.case "ModelDisplayPricing" to model.updateOptionMap() so DB-loaded values hydrate the in-memory display pricing cache during startup and option sync.model.UpdateOption(ModelDisplayPricingOptionKey, ModelDisplayPricing2JSONString()).model.RefreshPricing() after successful create, update, or delete so /api/pricing reflects the new display data immediately.Extend model.Pricing:
DisplayPricing []types.ModelDisplayPricingItem `json:"display_pricing,omitempty"`
During model.updatePricing(), after the model metadata and real pricing fields are assembled, attach display pricing for the model if configured. This keeps /api/pricing as the single source used by the existing pricing page.
/api/pricing/user/*model should also return display_pricing when present, but it must not use it for original_price, user_price, original_input, original_output, or savings calculation.
Admin APIs should mirror the existing model pricing rule APIs:
GET /api/option/model_display_pricingGET /api/option/model_display_pricing/*modelPUT /api/option/model_display_pricing/*modelDELETE /api/option/model_display_pricing/*modelUse wildcard model parameters, matching /api/pricing/user/*model, so model names containing / can be configured without URL-shape bugs. These endpoints manage only display data and call model.RefreshPricing() after updates.
The display pricing UI is part of the existing model pricing page. It should be implemented as a display override on top of the current /api/pricing response, not as a new standalone public page.
Affected frontend entry points:
web/src/hooks/model-pricing/useModelPricingData.jsx: keep loading /api/pricing; no extra fetch is needed for public display.web/src/helpers/utils.jsx: add shared helpers so table, card, and detail views render the same display price.web/src/components/table/model-pricing/view/table/PricingTableColumns.jsx: compact price column display.web/src/components/table/model-pricing/view/card/PricingCardView.jsx: compact card display.web/src/components/table/model-pricing/modal/components/ModelPricingTable.jsx: full detail table display.web/src/components/table/model-pricing/modal/components/UserPriceComparison.jsx: hide when display pricing exists.Add display pricing helpers in the model pricing utilities:
hasDisplayPricing(record)normalizeDisplayPricingItems(record)formatDisplayPricingItem({ item, displayPrice, t })summarizeDisplayPricing({ record, displayPrice, t })Display calculation:
original = displayPrice(item.price)
discounted = displayPrice(item.price * item.discount_rate)
If discount_rate is 1, show only the regular price. If lower than 1, show discounted price and optionally the original price with strikethrough.
Unit labels should be translated in the frontend. The API returns stable unit keys such as second, call, image, and video; the UI maps them to localized labels such as / second or / sec depending on existing i18n conventions.
Display priority:
record.display_pricing exists and has items, render display pricing.In the main table price column, display pricing replaces the current matrix/per-token/per-call price block for that model.
For multiple display pricing items with the same unit, show a converted price range:
CNY 2.41 - CNY 4.22 / second
Display price
For one item, or when all items have the same discounted price:
CNY 2.41 / second
Display price
For multiple units, group by unit and render one short line per unit:
CNY 2.41 - CNY 4.22 / second
CNY 1.00 / image
Display price
The compact table view should not render official_supplier_tip; that belongs in the detail view.
Cards should use the same summary output as the table column, with at most the first three display items shown below the range:
CNY 2.41 - CNY 4.22 / second
768p-6s CNY 2.41 / second
768p-10s CNY 2.90 / second
1080p CNY 4.22 / second
+ 2 more
If the card is too narrow on mobile, keep only the range and the Display price label. Do not render a horizontal table inside the card.
When display_pricing exists, ModelPricingTable should render a dedicated display pricing table instead of the existing group price table or matrix table.
| Specification | Supplier Tip | Price | Discount |
|---|---|---|---|
| 768p-6s | Text-to-video and image-to-video, 768P 6s | CNY 2.41 / second | - |
| 768p-10s | Text-to-video and image-to-video, 768P 10s | CNY 2.90 / second | - |
| 1080p | Text-to-video and image-to-video, 1080P | CNY 4.22 / second | - |
For discounted items, render the discounted price as the primary value and the original converted price as secondary strikethrough text:
CNY 1.93 / second
Original CNY 2.41, 20% off
Every display pricing block must include an i18n note with this meaning:
Display price is only an estimate. Actual consumption is based on the final quota deduction after the task completes.
The note must appear in the detail side sheet and in any compact tooltip/popover if one is added later. The main table and card can show only a short Display price label to avoid visual noise.
When a model has display_pricing, hide the old UserPriceComparison discount card. The detail side sheet should show the display pricing table and the estimate note instead. The current discount card is derived from real billing fields and would be misleading for models whose visible price is only an estimate.
/api/pricing/user/*model may still return display_pricing for consistency, but the frontend should not calculate user-specific discounted display pricing from original_price or user_price.
The first implementation may manage ModelDisplayPricing through JSON option editing or a minimal admin form. If a structured form is added, it should expose only display fields:
specificationofficial_supplier_tipprice as USD base priceunitsort_orderdiscount_rateThe editor must label price as USD base display price and include a warning that it does not affect real billing.
The implementation must not reference display pricing in:
relay/helper/price.gorelay/helper/pricing_lookup.gocontroller/relay.go pricing preload logicservice/task_polling.gotypes.PricingDecisionOnly admin display-pricing config APIs, model.Pricing, and pricing-page APIs should expose it. Relay, billing, task, and consume-log paths must not read it.
Admin saves display pricing
-> options.ModelDisplayPricing
-> ratio_setting display pricing cache
-> model.RefreshPricing()
-> model.updatePricing() attaches display_pricing
-> GET /api/pricing returns display_pricing
-> frontend price page renders display SKU table
User creates a task
-> relay pricing preload reads ModelPricingRules or legacy price/ratio
-> PricingDecision is frozen
-> task completes
-> final settlement uses real billing data
-> display_pricing is never read
Backend tests:
ModelDisplayPricing JSON.discount_rate to 1.model.InitOptionMap() initializes ModelDisplayPricing and model.updateOptionMap() hydrates the display pricing cache from DB-loaded option values.model.GetPricingByModel() includes sorted DisplayPricing.PricingConfig behavior is unchanged when display pricing exists./api/pricing/user/*model returns display_pricing but does not use it for computed prices./.Frontend tests:
hasDisplayPricing() detects display pricing before matrix pricing.Manual verification:
display_pricing.price.