Skip to content

xai://

xAI — Grok models via an OpenAI-compatible API.

Built on pkg/component/llmutil/ — the same chat/embeddings shape as openai://. This page covers only the xAI-specific defaults.

URI shape

xai://chat?model=<id>&apiKey=<key>&temperature=<float>&maxTokens=<int>&baseURL=<url>

Parameters

Param Type Default Producer/Consumer/Both Description
path enum chat Producer chat (embeddings not currently offered by xAI).
model string grok-2-latest Producer xAI Grok model id. Common: grok-2-latest, grok-2-vision-1212, grok-beta. See https://docs.x.ai/docs/models.
apiKey string (from constructor) Producer xAI API key. Sent as Authorization: Bearer <key>.
baseURL string https://api.x.ai/v1 Producer Override for proxies.
temperature float 0.7 Producer Sampling temperature.
maxTokens int 4096 Producer Output cap.

Producer-only. Default timeout 120 s.

Headers

Namespaced under xai.* (xai.model, xai.id, xai.finishReason, xai.usage.*). Input header systemPrompt works the same way.

Examples

- to: xai://chat?model=grok-2-latest&apiKey=${XAI_API_KEY}

Behavior notes

See openai://. Grok's vision variant (grok-2-vision-...) needs multimodal inputs which this raw HTTP client does not support — use the agent component for multimodal Grok.

Source

  • pkg/component/xai/xai.go.
  • pkg/component/llmutil/llmutil.go.

See also