@@ -14,6 +14,7 @@ type ModelInfoViewProps = {
1414 modelInfo ?: ModelInfo
1515 isDescriptionExpanded : boolean
1616 setIsDescriptionExpanded : ( isExpanded : boolean ) => void
17+ serviceTier ?: "auto" | "default" | "flex"
1718}
1819
1920export const ModelInfoView = ( {
@@ -22,9 +23,27 @@ export const ModelInfoView = ({
2223 modelInfo,
2324 isDescriptionExpanded,
2425 setIsDescriptionExpanded,
26+ serviceTier,
2527} : ModelInfoViewProps ) => {
2628 const { t } = useAppTranslation ( )
2729
30+ // Calculate effective pricing based on service tier
31+ const getEffectivePricing = ( modelInfo : ModelInfo ) => {
32+ if ( serviceTier === "flex" && ( modelInfo as any ) . flexPrice ) {
33+ const flexPrice = ( modelInfo as any ) . flexPrice
34+ return {
35+ ...modelInfo ,
36+ inputPrice : flexPrice . inputPrice ?? modelInfo . inputPrice ,
37+ outputPrice : flexPrice . outputPrice ?? modelInfo . outputPrice ,
38+ cacheReadsPrice : flexPrice . cacheReadsPrice ?? modelInfo . cacheReadsPrice ,
39+ cacheWritesPrice : flexPrice . cacheWritesPrice ?? modelInfo . cacheWritesPrice ,
40+ }
41+ }
42+ return modelInfo
43+ }
44+
45+ const effectiveModelInfo = modelInfo ? getEffectivePricing ( modelInfo ) : modelInfo
46+
2847 const infoItems = [
2948 < ModelInfoSupportsItem
3049 isSupported = { modelInfo ?. supportsImages ?? false }
@@ -47,28 +66,28 @@ export const ModelInfoView = ({
4766 { modelInfo . maxTokens ?. toLocaleString ( ) } tokens
4867 </ >
4968 ) ,
50- modelInfo ?. inputPrice !== undefined && modelInfo . inputPrice > 0 && (
69+ effectiveModelInfo ?. inputPrice !== undefined && effectiveModelInfo . inputPrice > 0 && (
5170 < >
5271 < span className = "font-medium" > { t ( "settings:modelInfo.inputPrice" ) } :</ span > { " " }
53- { formatPrice ( modelInfo . inputPrice ) } / 1M tokens
72+ { formatPrice ( effectiveModelInfo . inputPrice ) } / 1M tokens
5473 </ >
5574 ) ,
56- modelInfo ?. outputPrice !== undefined && modelInfo . outputPrice > 0 && (
75+ effectiveModelInfo ?. outputPrice !== undefined && effectiveModelInfo . outputPrice > 0 && (
5776 < >
5877 < span className = "font-medium" > { t ( "settings:modelInfo.outputPrice" ) } :</ span > { " " }
59- { formatPrice ( modelInfo . outputPrice ) } / 1M tokens
78+ { formatPrice ( effectiveModelInfo . outputPrice ) } / 1M tokens
6079 </ >
6180 ) ,
62- modelInfo ?. supportsPromptCache && modelInfo . cacheReadsPrice && (
81+ modelInfo ?. supportsPromptCache && effectiveModelInfo ? .cacheReadsPrice && (
6382 < >
6483 < span className = "font-medium" > { t ( "settings:modelInfo.cacheReadsPrice" ) } :</ span > { " " }
65- { formatPrice ( modelInfo . cacheReadsPrice || 0 ) } / 1M tokens
84+ { formatPrice ( effectiveModelInfo . cacheReadsPrice || 0 ) } / 1M tokens
6685 </ >
6786 ) ,
68- modelInfo ?. supportsPromptCache && modelInfo . cacheWritesPrice && (
87+ modelInfo ?. supportsPromptCache && effectiveModelInfo ? .cacheWritesPrice && (
6988 < >
7089 < span className = "font-medium" > { t ( "settings:modelInfo.cacheWritesPrice" ) } :</ span > { " " }
71- { formatPrice ( modelInfo . cacheWritesPrice || 0 ) } / 1M tokens
90+ { formatPrice ( effectiveModelInfo . cacheWritesPrice || 0 ) } / 1M tokens
7291 </ >
7392 ) ,
7493 apiProvider === "gemini" && (
0 commit comments