Skip to content

XAIBackendAdapter

Defined in: backend/src/providers/xai.ts:110

Backend adapter for xAI (Grok) Chat Completions API.

Features:

  • Grok models with real-time search capabilities
  • OpenAI-compatible API
  • 2M context window
  • Vision model support (Grok-vision)
  • Function calling support
  • Premium pricing ($5-$15 per 1M tokens)

new XAIBackendAdapter(config): XAIBackendAdapter

Defined in: backend/src/providers/xai.ts:115

BackendAdapterConfig

XAIBackendAdapter

readonly metadata: AdapterMetadata

Defined in: backend/src/providers/xai.ts:111

Adapter metadata for identification and capabilities.

BackendAdapter.metadata

estimateCost(request): Promise<number | null>

Defined in: backend/src/providers/xai.ts:450

Estimate cost.

IRChatRequest

Promise<number | null>

BackendAdapter.estimateCost


execute(request, signal?): Promise<IRChatResponse>

Defined in: backend/src/providers/xai.ts:250

Execute non-streaming request.

IRChatRequest

AbortSignal

Promise<IRChatResponse>

BackendAdapter.execute


executeStream(request, signal?): IRChatStream

Defined in: backend/src/providers/xai.ts:292

Execute streaming request.

IRChatRequest

AbortSignal

IRChatStream

BackendAdapter.executeStream


fromIR(request): XAIRequest

Defined in: backend/src/providers/xai.ts:146

Convert IR to xAI format.

IRChatRequest

XAIRequest

BackendAdapter.fromIR


healthCheck(): Promise<boolean>

Defined in: backend/src/providers/xai.ts:434

Health check.

Promise<boolean>

BackendAdapter.healthCheck


toIR(response, originalRequest, latencyMs): IRChatResponse

Defined in: backend/src/providers/xai.ts:192

Convert xAI response to IR.

XAIResponse

IRChatRequest

number

IRChatResponse

BackendAdapter.toIR