@@ -33,6 +33,8 @@ import {
3333 openRouterDefaultModelInfo ,
3434 vertexDefaultModelId ,
3535 vertexModels ,
36+ xaiDefaultModelId ,
37+ xaiModels ,
3638} from "../../../../src/shared/api"
3739import { ExtensionMessage } from "../../../../src/shared/ExtensionMessage"
3840import { useExtensionState } from "../../context/ExtensionStateContext"
@@ -195,6 +197,7 @@ const ApiOptions = ({ showModelOptions, apiErrorMessage, modelIdErrorMessage, is
195197 < VSCodeOption value = "lmstudio" > LM Studio</ VSCodeOption >
196198 < VSCodeOption value = "ollama" > Ollama</ VSCodeOption >
197199 < VSCodeOption value = "litellm" > LiteLLM</ VSCodeOption >
200+ < VSCodeOption value = "xai" > X AI</ VSCodeOption >
198201 </ VSCodeDropdown >
199202 </ DropdownContainer >
200203
@@ -1122,6 +1125,46 @@ const ApiOptions = ({ showModelOptions, apiErrorMessage, modelIdErrorMessage, is
11221125 </ div >
11231126 ) }
11241127
1128+ { selectedProvider === "xai" && (
1129+ < div >
1130+ < VSCodeTextField
1131+ value = { apiConfiguration ?. xaiApiKey || "" }
1132+ style = { { width : "100%" } }
1133+ type = "password"
1134+ onInput = { handleInputChange ( "xaiApiKey" ) }
1135+ placeholder = "Enter API Key..." >
1136+ < span style = { { fontWeight : 500 } } > X AI API Key</ span >
1137+ </ VSCodeTextField >
1138+ < p
1139+ style = { {
1140+ fontSize : "12px" ,
1141+ marginTop : 3 ,
1142+ color : "var(--vscode-descriptionForeground)" ,
1143+ } } >
1144+ This key is stored locally and only used to make API requests from this extension.
1145+ { ! apiConfiguration ?. xaiApiKey && (
1146+ < VSCodeLink href = "https://x.ai" style = { { display : "inline" , fontSize : "inherit" } } >
1147+ You can get an X AI API key by signing up here.
1148+ </ VSCodeLink >
1149+ ) }
1150+ </ p >
1151+ { /* Note: To fully implement this, you would need to add a handler in ClineProvider.ts */ }
1152+ { /* {apiConfiguration?.xaiApiKey && (
1153+ <button
1154+ onClick={() => {
1155+ vscode.postMessage({
1156+ type: "requestXAIModels",
1157+ text: apiConfiguration?.xaiApiKey,
1158+ })
1159+ }}
1160+ style={{ margin: "5px 0 0 0" }}
1161+ className="vscode-button">
1162+ Fetch Available Models
1163+ </button>
1164+ )} */ }
1165+ </ div >
1166+ ) }
1167+
11251168 { apiErrorMessage && (
11261169 < p
11271170 style = { {
@@ -1152,6 +1195,7 @@ const ApiOptions = ({ showModelOptions, apiErrorMessage, modelIdErrorMessage, is
11521195 { selectedProvider === "deepseek" && createDropdown ( deepSeekModels ) }
11531196 { selectedProvider === "qwen" && createDropdown ( qwenModels ) }
11541197 { selectedProvider === "mistral" && createDropdown ( mistralModels ) }
1198+ { selectedProvider === "xai" && createDropdown ( xaiModels ) }
11551199 </ DropdownContainer >
11561200
11571201 < ModelInfoView
@@ -1403,6 +1447,8 @@ export function normalizeApiConfiguration(apiConfiguration?: ApiConfiguration):
14031447 selectedModelId : apiConfiguration ?. liteLlmModelId || "" ,
14041448 selectedModelInfo : openAiModelInfoSaneDefaults ,
14051449 }
1450+ case "xai" :
1451+ return getProviderData ( xaiModels , xaiDefaultModelId )
14061452 default :
14071453 return getProviderData ( anthropicModels , anthropicDefaultModelId )
14081454 }
0 commit comments