@@ -749,29 +749,41 @@ impl crate::routers::RouterTrait for OpenAIRouter {
]{
obj.remove(key);
}
// XAI doesn't support the OPENAI item type input: https://platform.openai.com/docs/api-reference/responses/create#responses-create-input-input-item-list-item
// To Achieve XAI compatibility, strip extra fields from input messages (id, status)
// XAI doesn't support output_text as type for content with role of assistant
// so normalize content types: output_text -> input_text
// XAI (Grok models) requires special handling of input items
// Check if model is a Grok model
letis_grok_model=obj
.get("model")
.and_then(|v|v.as_str())
.map(|m|m.starts_with("grok"))
.unwrap_or(false);
ifis_grok_model{
// XAI doesn't support the OPENAI item type input: https://platform.openai.com/docs/api-reference/responses/create#responses-create-input-input-item-list-item
// To Achieve XAI compatibility, strip extra fields from input messages (id, status)
// XAI doesn't support output_text as type for content with role of assistant
// so normalize content types: output_text -> input_text