XAIProvider class

xAI Provider implementation

This is the main provider class that implements capability interfaces and delegates to specialized modules for different functionalities.

Supported Capabilities:

  • Chat with Grok models
  • Real-time web search (Live Search)
  • Function/tool calling
  • Vector embeddings
  • Reasoning and thinking (Grok models)
  • Vision capabilities (Grok Vision models)
Implemented types

Constructors

XAIProvider.new(XAIConfig config)

Properties

client XAIClient
final
config XAIConfig
final
hashCode int
The hash code for this object.
no setterinherited
info Map<String, dynamic>
Get provider information
no setter
providerName String
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
supportedCapabilities Set<LLMCapability>
Set of capabilities this provider supports
no setteroverride

Methods

chat(List<ChatMessage> messages) Future<ChatResponse>
Sends a chat request to the provider with a sequence of messages.
override
chatStream(List<ChatMessage> messages, {List<Tool>? tools}) Stream<ChatStreamEvent>
Sends a streaming chat request to the provider
override
chatWithTools(List<ChatMessage> messages, List<Tool>? tools) Future<ChatResponse>
Sends a chat request to the provider with a sequence of messages and tools.
override
copyWith({String? apiKey, String? baseUrl, String? model, int? maxTokens, double? temperature, String? systemPrompt, Duration? timeout, bool? stream, double? topP, int? topK, List<Tool>? tools, ToolChoice? toolChoice, StructuredOutputFormat? jsonSchema, String? embeddingEncodingFormat, int? embeddingDimensions, SearchParameters? searchParameters, bool? liveSearch}) XAIProvider
Create a new provider with updated configuration
embed(List<String> input) Future<List<List<double>>>
Generate embeddings for the given input texts
override
memoryContents() Future<List<ChatMessage>?>
Get current memory contents if provider supports memory
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
summarizeHistory(List<ChatMessage> messages) Future<String>
Summarizes a conversation history into a concise 2-3 sentence summary
override
supports(LLMCapability capability) bool
Check if this provider supports a specific capability
override
supportsCapability(Type capability) bool
Check if the provider supports a specific capability
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited