@@ -10,6 +10,8 @@ import {
1010 moonshotModels ,
1111 minimaxModels ,
1212 mimoModels ,
13+ bailianModels ,
14+ bailianDefaultModelId ,
1315 geminiModels ,
1416 mistralModels ,
1517 openAiModelInfoSaneDefaults ,
@@ -33,6 +35,7 @@ import {
3335 isDynamicProvider ,
3436 isRetiredProvider ,
3537 getProviderDefaultModelId ,
38+ getBailianPrice ,
3639} from "@roo-code/types"
3740
3841import { useRouterModels } from "./useRouterModels"
@@ -120,6 +123,40 @@ export const useSelectedModel = (apiConfiguration?: ProviderSettings) => {
120123 }
121124}
122125
126+ /**
127+ * Per-provider pricing overrides.
128+ *
129+ * Each function receives (modelId, apiConfiguration) and returns a partial
130+ * ModelInfo whose price fields (inputPrice, outputPrice, cacheReadsPrice,
131+ * cacheWritesPrice) are merged OVER the static model definition.
132+ *
133+ * Add an entry here when a provider needs runtime-computed pricing (region-
134+ * specific, volume-tiered, etc.) that cannot be expressed in static model data.
135+ */
136+ const PROVIDER_PRICING_FNS : Partial <
137+ Record <
138+ ProviderName ,
139+ ( modelId : string , config : ProviderSettings ) => Partial < ModelInfo > | undefined
140+ >
141+ > = {
142+ bailian : ( id , config ) => {
143+ const region = ( config . bailianRegion ?? "beijing" ) as Parameters < typeof getBailianPrice > [ 1 ]
144+ return getBailianPrice ( id , region )
145+ } ,
146+ }
147+
148+ /** Apply per-provider pricing overrides on top of static baseInfo. */
149+ function resolveModelInfo (
150+ baseInfo : ModelInfo | undefined ,
151+ provider : ProviderName ,
152+ modelId : string ,
153+ config : ProviderSettings ,
154+ ) : ModelInfo | undefined {
155+ if ( ! baseInfo ) return undefined
156+ const pricing = PROVIDER_PRICING_FNS [ provider ] ?.( modelId , config )
157+ return pricing ? { ...baseInfo , ...pricing } : baseInfo
158+ }
159+
123160function getSelectedModel ( {
124161 provider,
125162 apiConfiguration,
@@ -257,6 +294,22 @@ function getSelectedModel({
257294 const info = mimoModels [ id as keyof typeof mimoModels ] ?? mimoModels [ "mimo-v2.5-pro" ]
258295 return { id, info }
259296 }
297+ case "bailian" : {
298+ const id = apiConfiguration . apiModelId ?? defaultModelId
299+ const baseInfo = bailianModels [ id as keyof typeof bailianModels ]
300+ // Custom models: merge default model info with bailianCustomModelInfo,
301+ // matching the API handler's getModel() fallback.
302+ // Note: supportsReasoningBinary is inherited from the default model
303+ // (qwen3.6-plus). Custom models that do not support enable_thinking
304+ // should disable reasoning via the UI checkbox.
305+ const effectiveInfo = baseInfo
306+ ?? {
307+ ...bailianModels [ defaultModelId as keyof typeof bailianModels ] ,
308+ ...( apiConfiguration . bailianCustomModelInfo || { } ) ,
309+ }
310+ const info = resolveModelInfo ( effectiveInfo , provider , id , apiConfiguration )
311+ return { id, info }
312+ }
260313 case "zai" : {
261314 const isChina = apiConfiguration . zaiApiLine === "china_coding"
262315 const models = isChina ? mainlandZAiModels : internationalZAiModels
0 commit comments