xai
@providerprotocol/ai / xai
xAI provider for UPP (Unified Provider Protocol)
This module exports the xAI provider for use with the Grok family of models. xAI’s APIs are compatible with both OpenAI and Anthropic SDKs.
Example
Section titled “Example”import { xai } from '@providerprotocol/ai/xai';import { llm } from '@providerprotocol/ai';
// Create an LLM instance with Grokconst model = llm({ model: xai('grok-4'), params: { max_tokens: 1000 }});
// Generate a responseconst turn = await model.generate('What is the meaning of life?');console.log(turn.response.text);Interfaces
Section titled “Interfaces”XAIAgentTool- XAICodeExecutionTool
- XAICompletionsParams
- XAIConfig
- XAIFileSearchTool
- XAIHeaders
- XAIMcpTool
- XAIMessagesParams
- XAIModelOptions
- XAIModelReference
- XAIProviderOptions
- XAIResponsesParams
- XAIServerSideToolUsage
- XAIWebSearchTool
- XAIXSearchTool