@@ -51,7 +51,7 @@ import { useExtensionState } from "../../context/ExtensionStateContext"
5151import { vscode } from "../../utils/vscode"
5252import { getAsVar , VSC_DESCRIPTION_FOREGROUND } from "../../utils/vscStyles"
5353import VSCodeButtonLink from "../common/VSCodeButtonLink"
54- import OpenRouterModelPicker , { ModelDescriptionMarkdown } from "./OpenRouterModelPicker"
54+ import OpenRouterModelPicker , { ModelDescriptionMarkdown , OPENROUTER_MODEL_PICKER_Z_INDEX } from "./OpenRouterModelPicker"
5555import { ClineAccountInfoCard } from "./ClineAccountInfoCard"
5656
5757interface ApiOptionsProps {
@@ -95,6 +95,7 @@ const ApiOptions = ({ showModelOptions, apiErrorMessage, modelIdErrorMessage, is
9595 const [ awsEndpointSelected , setAwsEndpointSelected ] = useState ( ! ! apiConfiguration ?. awsBedrockEndpoint )
9696 const [ modelConfigurationSelected , setModelConfigurationSelected ] = useState ( false )
9797 const [ isDescriptionExpanded , setIsDescriptionExpanded ] = useState ( false )
98+ const [ providerSortingSelected , setProviderSortingSelected ] = useState ( ! ! apiConfiguration ?. openRouterProviderSorting )
9899
99100 const handleInputChange = ( field : keyof ApiConfiguration ) => ( event : any ) => {
100101 setApiConfiguration ( {
@@ -1353,6 +1354,57 @@ const ApiOptions = ({ showModelOptions, apiErrorMessage, modelIdErrorMessage, is
13531354 </ p >
13541355 ) }
13551356
1357+ { ( selectedProvider === "openrouter" || selectedProvider === "cline" ) && showModelOptions && (
1358+ < >
1359+ < VSCodeCheckbox
1360+ style = { { marginTop : - 10 } }
1361+ checked = { providerSortingSelected }
1362+ onChange = { ( e : any ) => {
1363+ const isChecked = e . target . checked === true
1364+ setProviderSortingSelected ( isChecked )
1365+ if ( ! isChecked ) {
1366+ setApiConfiguration ( {
1367+ ...apiConfiguration ,
1368+ openRouterProviderSorting : "" ,
1369+ } )
1370+ }
1371+ } } >
1372+ Sort underlying provider routing
1373+ </ VSCodeCheckbox >
1374+
1375+ { providerSortingSelected && (
1376+ < div style = { { marginBottom : - 6 } } >
1377+ < DropdownContainer className = "dropdown-container" zIndex = { OPENROUTER_MODEL_PICKER_Z_INDEX - 3 } >
1378+ < VSCodeDropdown
1379+ style = { { width : "100%" , marginTop : 3 } }
1380+ value = { apiConfiguration ?. openRouterProviderSorting }
1381+ onChange = { ( e : any ) => {
1382+ setApiConfiguration ( {
1383+ ...apiConfiguration ,
1384+ openRouterProviderSorting : e . target . value ,
1385+ } )
1386+ } } >
1387+ < VSCodeOption value = "" > Default</ VSCodeOption >
1388+ < VSCodeOption value = "price" > Price</ VSCodeOption >
1389+ < VSCodeOption value = "throughput" > Throughput</ VSCodeOption >
1390+ < VSCodeOption value = "latency" > Latency</ VSCodeOption >
1391+ </ VSCodeDropdown >
1392+ </ DropdownContainer >
1393+ < p style = { { fontSize : "12px" , marginTop : 3 , color : "var(--vscode-descriptionForeground)" } } >
1394+ { ! apiConfiguration ?. openRouterProviderSorting &&
1395+ "Default behavior is to load balance requests across providers (like AWS, Google Vertex, Anthropic), prioritizing price while considering provider uptime" }
1396+ { apiConfiguration ?. openRouterProviderSorting === "price" &&
1397+ "Sort providers by price, prioritizing the lowest cost provider" }
1398+ { apiConfiguration ?. openRouterProviderSorting === "throughput" &&
1399+ "Sort providers by throughput, prioritizing the provider with the highest throughput (may increase cost)" }
1400+ { apiConfiguration ?. openRouterProviderSorting === "latency" &&
1401+ "Sort providers by response time, prioritizing the provider with the lowest latency" }
1402+ </ p >
1403+ </ div >
1404+ ) }
1405+ </ >
1406+ ) }
1407+
13561408 { selectedProvider !== "openrouter" &&
13571409 selectedProvider !== "cline" &&
13581410 selectedProvider !== "openai" &&
0 commit comments