@@ -26,6 +26,12 @@ export function isCodingPlanBaseURL(baseURL: string | undefined): boolean {
2626 }
2727}
2828
29+ // First-class Z.AI Coding Plan catalog id. Live /model identity uses this
30+ // name, not the launch baseURL, so a switch onto or off zai updates $ now.
31+ export function isCodingPlanProviderName ( name : string ) : boolean {
32+ return name === "zai" ;
33+ }
34+
2935// Codex OAuth bills against the user's ChatGPT subscription via
3036// chatgpt.com/backend-api. Public per-token rates for the same model ids do
3137// not apply there, so dollar estimates must be suppressed. Matched against
@@ -60,8 +66,10 @@ export function isFreeModelByPricing(cache: PricingCache | null, modelId: string
6066export interface CostVisibilityInput {
6167 baseURL ?: string | undefined ;
6268 // Live /model identity. When set, it wins over a stale launch baseURL for
63- // the ChatGPT-subscription hide: Codex names hide even on api.openai.com,
64- // non-Codex names show even on CODEX_BASE_URL. Undefined falls back to URL.
69+ // ChatGPT-subscription and coding-plan hides: Codex names hide even on
70+ // api.openai.com, zai names hide even on a metered URL; a present
71+ // non-matching name shows even when launch URL would hide. Undefined
72+ // falls back to URL.
6573 providerName ?: string | undefined ;
6674 modelId : string ;
6775 providerFree ?: boolean | undefined ;
@@ -71,6 +79,13 @@ export interface CostVisibilityInput {
7179export type CostHiddenReason =
7280 "provider-free" | "coding-plan" | "chatgpt-subscription" | "free-model" | "zero-priced" ;
7381
82+ function isCodingPlanSession ( input : CostVisibilityInput ) : boolean {
83+ if ( input . providerName !== undefined ) {
84+ return isCodingPlanProviderName ( input . providerName ) ;
85+ }
86+ return isCodingPlanBaseURL ( input . baseURL ) ;
87+ }
88+
7489function isChatGPTSubscriptionSession ( input : CostVisibilityInput ) : boolean {
7590 if ( input . providerName !== undefined ) {
7691 return isCodexProviderName ( input . providerName ) ;
@@ -79,13 +94,14 @@ function isChatGPTSubscriptionSession(input: CostVisibilityInput): boolean {
7994}
8095
8196// Non-null when the dollar cost should be suppressed: a manual provider
82- // override, a coding-plan endpoint, a ChatGPT/Codex subscription (live
83- // provider identity, else Codex URL), a free-named model, or a model the
84- // pricing registry reports as zero-cost. The reason is carried to the
85- // display so /cost can say which condition hid the figure.
97+ // override, a coding-plan session (live zai identity, else /coding URL), a
98+ // ChatGPT/Codex subscription (live provider identity, else Codex URL), a
99+ // free-named model, or a model the pricing registry reports as zero-cost.
100+ // The reason is carried to the display so /cost can say which condition hid
101+ // the figure.
86102export function costHiddenReason ( input : CostVisibilityInput ) : CostHiddenReason | null {
87103 if ( input . providerFree === true ) return "provider-free" ;
88- if ( isCodingPlanBaseURL ( input . baseURL ) ) return "coding-plan" ;
104+ if ( isCodingPlanSession ( input ) ) return "coding-plan" ;
89105 if ( isChatGPTSubscriptionSession ( input ) ) return "chatgpt-subscription" ;
90106 if ( isFreeModelId ( input . modelId ) ) return "free-model" ;
91107 return isFreeModelByPricing ( input . pricingCache , input . modelId ) ? "zero-priced" : null ;
0 commit comments