@@ -176,6 +176,8 @@ pub struct ProvidersToml {
176176 alias = "meituan"
177177 ) ]
178178 pub longcat : ProviderConfigToml ,
179+ #[ serde( default , alias = "x-ai" , alias = "x_ai" , alias = "grok" ) ]
180+ pub xai : ProviderConfigToml ,
179181 /// Catch-all table for the dynamic OpenAI-compatible custom provider
180182 /// identity (#1519). Arbitrary `[providers.<name>]` tables are handled by
181183 /// the tui-side flatten map; this named slot keeps the canonical
@@ -275,6 +277,7 @@ impl ProvidersToml {
275277 ProviderKind :: Deepinfra => & self . deepinfra ,
276278 ProviderKind :: Sakana => & self . sakana ,
277279 ProviderKind :: LongCat => & self . longcat ,
280+ ProviderKind :: Xai => & self . xai ,
278281 ProviderKind :: Custom => & self . custom ,
279282 }
280283 }
@@ -311,6 +314,7 @@ impl ProvidersToml {
311314 ProviderKind :: Deepinfra => & mut self . deepinfra ,
312315 ProviderKind :: Sakana => & mut self . sakana ,
313316 ProviderKind :: LongCat => & mut self . longcat ,
317+ ProviderKind :: Xai => & mut self . xai ,
314318 ProviderKind :: Custom => & mut self . custom ,
315319 }
316320 }
@@ -2042,6 +2046,7 @@ impl ConfigToml {
20422046 ProviderKind :: Deepinfra => DEFAULT_DEEPINFRA_BASE_URL . to_string ( ) ,
20432047 ProviderKind :: Sakana => DEFAULT_SAKANA_BASE_URL . to_string ( ) ,
20442048 ProviderKind :: LongCat => DEFAULT_LONGCAT_BASE_URL . to_string ( ) ,
2049+ ProviderKind :: Xai => DEFAULT_XAI_BASE_URL . to_string ( ) ,
20452050 // The custom provider has no built-in endpoint; fall back to its
20462051 // descriptor placeholder so the lookup is total. Real custom
20472052 // routes always supply a configured base_url before this point.
@@ -2294,6 +2299,7 @@ fn normalize_model_for_provider(provider: ProviderKind, model: &str) -> String {
22942299 | ProviderKind :: Minimax
22952300 | ProviderKind :: Qianfan
22962301 | ProviderKind :: Ollama
2302+ | ProviderKind :: Xai
22972303 ) {
22982304 return model. to_string ( ) ;
22992305 }
@@ -2619,6 +2625,7 @@ fn default_model_for_provider(provider: ProviderKind) -> &'static str {
26192625 ProviderKind :: Deepinfra => DEFAULT_DEEPINFRA_MODEL ,
26202626 ProviderKind :: Sakana => DEFAULT_SAKANA_MODEL ,
26212627 ProviderKind :: LongCat => DEFAULT_LONGCAT_MODEL ,
2628+ ProviderKind :: Xai => DEFAULT_XAI_MODEL ,
26222629 // No built-in default model; the registry placeholder keeps this total.
26232630 ProviderKind :: Custom => provider. provider ( ) . default_model ( ) ,
26242631 }
@@ -2656,6 +2663,7 @@ fn default_base_url_for_provider(provider: ProviderKind) -> &'static str {
26562663 ProviderKind :: Deepinfra => DEFAULT_DEEPINFRA_BASE_URL ,
26572664 ProviderKind :: Sakana => DEFAULT_SAKANA_BASE_URL ,
26582665 ProviderKind :: LongCat => DEFAULT_LONGCAT_BASE_URL ,
2666+ ProviderKind :: Xai => DEFAULT_XAI_BASE_URL ,
26592667 // No built-in default base URL; the registry placeholder keeps this total.
26602668 ProviderKind :: Custom => provider. provider ( ) . default_base_url ( ) ,
26612669 }
@@ -4201,6 +4209,8 @@ struct EnvRuntimeOverrides {
42014209 sakana_model : Option < String > ,
42024210 longcat_base_url : Option < String > ,
42034211 longcat_model : Option < String > ,
4212+ xai_base_url : Option < String > ,
4213+ xai_model : Option < String > ,
42044214}
42054215
42064216impl EnvRuntimeOverrides {
@@ -4445,6 +4455,12 @@ impl EnvRuntimeOverrides {
44454455 longcat_model : std:: env:: var ( "LONGCAT_MODEL" )
44464456 . ok ( )
44474457 . filter ( |v| !v. trim ( ) . is_empty ( ) ) ,
4458+ xai_base_url : std:: env:: var ( "XAI_BASE_URL" )
4459+ . ok ( )
4460+ . filter ( |v| !v. trim ( ) . is_empty ( ) ) ,
4461+ xai_model : std:: env:: var ( "XAI_MODEL" )
4462+ . ok ( )
4463+ . filter ( |v| !v. trim ( ) . is_empty ( ) ) ,
44484464 }
44494465 }
44504466
@@ -4497,6 +4513,7 @@ impl EnvRuntimeOverrides {
44974513 ProviderKind :: Deepinfra => self . deepinfra_base_url . clone ( ) ,
44984514 ProviderKind :: Sakana => self . sakana_base_url . clone ( ) ,
44994515 ProviderKind :: LongCat => self . longcat_base_url . clone ( ) ,
4516+ ProviderKind :: Xai => self . xai_base_url . clone ( ) ,
45004517 // No dedicated CODEWHALE_CUSTOM_BASE_URL env override: a custom
45014518 // provider's base URL comes from its `[providers.<name>]` table.
45024519 ProviderKind :: Custom => None ,
@@ -4528,6 +4545,7 @@ impl EnvRuntimeOverrides {
45284545 ProviderKind :: Deepinfra => self . deepinfra_model . clone ( ) ,
45294546 ProviderKind :: Sakana => self . sakana_model . clone ( ) ,
45304547 ProviderKind :: LongCat => self . longcat_model . clone ( ) ,
4548+ ProviderKind :: Xai => self . xai_model . clone ( ) ,
45314549 _ => None ,
45324550 } ?;
45334551
0 commit comments