See ChatXAI docs for detail and supported features.
Copy
Ask AI
# Querying chat models with xAIfrom langchain_xai import ChatXAIchat = ChatXAI( # xai_api_key="YOUR_API_KEY", model="grok-4",)# stream the response back from the modelfor m in chat.stream("Tell me fun things to do in NYC"): print(m.content, end="", flush=True)# if you don't want to do streaming, you can use the invoke method# chat.invoke("Tell me fun things to do in NYC")
Assistant
Responses are generated using AI and may contain mistakes.