grok_4
What it is
- A module that defines a preconfigured
ChatModelinstance for the xAI Grok 4 chat model usinglangchain_xai.ChatXAI. - Includes default settings for temperature, token limit, and live search parameters.
Public API
model: ChatModel- A ready-to-use
ChatModelconfigured with:model_id="grok-4",provider="xai",context_window=200000- Underlying LangChain model:
ChatXAI(...)with:temperature=0.1max_tokens=4096api_keyfromABIModule.get_instance().configuration.xai_api_keysearch_parameters={"mode": "auto", "max_search_results": 5}(live search enabled)
- A ready-to-use
Configuration/Dependencies
- Dependencies:
langchain_xai.ChatXAInaas_abi_marketplace.ai.grok.ABIModulenaas_abi_core.models.Model.ChatModelpydantic.SecretStr
- Required configuration:
ABIModule.get_instance().configuration.xai_api_keymust be set (used to build theChatXAIclient).
Usage
from naas_abi_marketplace.ai.grok.models.grok_4 import model
# `model` is a ChatModel wrapping a ChatXAI client.
# Interactions depend on the ChatModel interface provided by naas_abi_core.
print(model.model_id) # "grok-4"
print(model.provider) # "xai"
Caveats
- Importing this module constructs the
ChatXAIinstance immediately; missing/invalidxai_api_keyin the ABIModule configuration will break initialization. - Live search is enabled by default via
search_parameters(mode="auto",max_search_results=5).