# 使用 xAI 查询聊天模型from langchain_xai import ChatXAIchat = ChatXAI( # xai_api_key="YOUR_API_KEY", model="grok-4",)# 从模型流式传输响应for m in chat.stream("Tell me fun things to do in NYC"): print(m.content, end="", flush=True)# 如果不想使用流式传输,可以使用 invoke 方法# chat.invoke("Tell me fun things to do in NYC")