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)
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new XAIBackendAdapter(
config):XAIBackendAdapter
Defined in: backend/src/providers/xai.ts:115
Parameters
Section titled “Parameters”config
Section titled “config”Returns
Section titled “Returns”XAIBackendAdapter
Properties
Section titled “Properties”metadata
Section titled “metadata”
readonlymetadata:AdapterMetadata
Defined in: backend/src/providers/xai.ts:111
Adapter metadata for identification and capabilities.
Implementation of
Section titled “Implementation of”Methods
Section titled “Methods”estimateCost()
Section titled “estimateCost()”estimateCost(
request):Promise<number|null>
Defined in: backend/src/providers/xai.ts:450
Estimate cost.
Parameters
Section titled “Parameters”request
Section titled “request”Returns
Section titled “Returns”Promise<number | null>
Implementation of
Section titled “Implementation of”execute()
Section titled “execute()”execute(
request,signal?):Promise<IRChatResponse>
Defined in: backend/src/providers/xai.ts:250
Execute non-streaming request.
Parameters
Section titled “Parameters”request
Section titled “request”signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”Promise<IRChatResponse>
Implementation of
Section titled “Implementation of”executeStream()
Section titled “executeStream()”executeStream(
request,signal?):IRChatStream
Defined in: backend/src/providers/xai.ts:292
Execute streaming request.
Parameters
Section titled “Parameters”request
Section titled “request”signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”fromIR()
Section titled “fromIR()”fromIR(
request):XAIRequest
Defined in: backend/src/providers/xai.ts:146
Convert IR to xAI format.
Parameters
Section titled “Parameters”request
Section titled “request”Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”healthCheck()
Section titled “healthCheck()”healthCheck():
Promise<boolean>
Defined in: backend/src/providers/xai.ts:434
Health check.
Returns
Section titled “Returns”Promise<boolean>
Implementation of
Section titled “Implementation of”toIR()
Section titled “toIR()”toIR(
response,originalRequest,latencyMs):IRChatResponse
Defined in: backend/src/providers/xai.ts:192
Convert xAI response to IR.
Parameters
Section titled “Parameters”response
Section titled “response”originalRequest
Section titled “originalRequest”latencyMs
Section titled “latencyMs”number