messages = [ ( "system", "You are a helpful assistant that translates English to French. Translate the user sentence.", ), ("human", "I love programming."),]ai_msg = llm.invoke(messages)ai_msg
from pydantic import BaseModel, Fieldclass GetWeather(BaseModel): """Get the current weather in a given location""" location: str = Field(description="The city and state, e.g. San Francisco, CA")llm_with_tools = llm.bind_tools([GetWeather])
ai_msg = llm_with_tools.invoke( "what is the weather like in San Francisco",)ai_msg
from langchain_xai import ChatXAIllm = ChatXAI(model="grok-4", temperature=0).bind_tools([{"type": "web_search"}])response = llm.invoke("Provide me a digest of world news in the last 24 hours.")response.content
from langchain_xai import ChatXAImodel = ChatXAI(model="grok-4.3")response = model.invoke( "Analyze the trade-offs between microservices and monolithic architectures", reasoning_effort="high",)