For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.
xAI
Configure kagent to use xAI Grok models through xAI’s OpenAI-compatible API.
xAI’s Grok models are served through an OpenAI-compatible API, so a ModelConfigModelConfigA Kubernetes custom resource naming one model at one provider, along with the credentials to reach it. An AgentTemplate references one by name, and every agent compiled from that template calls the model that it names.Learn more for xAI sets provider: OpenAI and points openAI.baseUrl at xAI. There is no separate xAI provider value.
Create the ModelConfig
Save your xAI API key as an environment variable.
export XAI_API_KEY=<your_api_key>Create a Kubernetes Secret that stores the API key. Create it in the same namespace as the AgentTemplates that use it, such as
kagent.kubectl create secret generic kagent-xai -n kagent --from-literal XAI_API_KEY=$XAI_API_KEYCreate a
ModelConfigthat references the Secret and sets the xAI base URL.kubectl apply -f - <<EOF apiVersion: kagent.dev/v1alpha3 kind: ModelConfig metadata: name: grok-model-config namespace: kagent spec: apiKeySecret: kagent-xai apiKeySecretKey: XAI_API_KEY model: grok-3 provider: OpenAI openAI: baseUrl: https://api.x.ai/v1 EOFField Description apiKeySecretThe name of the Kubernetes Secret that stores the API key, in the same namespace as this ModelConfig. apiKeySecretKeyThe key within that Secret that holds the API key. modelThe Grok model to use. For the available models, see the xAI model docs. providerThe provider to use, OpenAI. xAI is reached through the OpenAI provider.openAI.baseUrlThe xAI API endpoint, https://api.x.ai/v1.
For the rest of the settings that the openAI block accepts, see OpenAI. For every openAI field, including its type, default, and validation rules, see the API reference.
Use the ModelConfig
Reference the ModelConfig by name from an AgentTemplate in the same namespace.
spec:
modelConfig:
name: grok-model-config