XAIProvider class
Provider for xAI Grok via the OpenAI-compatible chat completions API.
- Inheritance
Constructors
-
XAIProvider({String? apiKey, Map<
String, String> headers = const {}}) - Creates a new xAI provider instance.
Properties
-
aliases
→ List<
String> -
Alternative names for lookup (e.g., 'claude' => 'anthropic').
finalinherited
- apiKey → String?
-
The API key for this provider.
finalinherited
- apiKeyName → String?
-
The environment variable for the API key (if any).
finalinherited
- baseUrl → Uri?
-
The default API endpoint for this provider.
finalinherited
-
defaultModelNames
→ Map<
ModelKind, String> -
The default model for this provider.
finalinherited
- defaultRestBaseUrl → Uri
-
Base URL used when an explicit embeddings endpoint is not provided.
no setterinherited
- displayName → String
-
Human-readable name for display.
finalinherited
- embeddingsApiBaseUrl → Uri
-
Resolved base URL for embeddings API calls.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
-
headers
→ Map<
String, String> -
Custom HTTP headers to include with all API requests.
finalinherited
- logger → Logger
-
Logger used by subclasses for shared operations.
no setterinherited
- modelsApiBaseUrl → Uri
-
Resolved base URL for listing models.
no setterinherited
- name → String
-
The canonical provider name (e.g., 'openai', 'ollama').
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
createChatModel(
{String? name, List< Tool< ? tools, double? temperature, bool enableThinking = false, OpenAIChatOptions? options}) → ChatModel<Object> >OpenAIChatOptions> -
Creates a chat model instance for this provider.
override
-
createEmbeddingsModel(
{String? name, OpenAIEmbeddingsModelOptions? options}) → EmbeddingsModel< OpenAIEmbeddingsModelOptions> - Creates an embeddings model instance for this provider.
-
createMediaModel(
{String? name, List< Tool< ? tools, MediaGenerationModelOptions? options, List<Object> >String> ? mimeTypes}) → MediaGenerationModel<MediaGenerationModelOptions> -
Creates a media generation model instance for this provider.
inherited
-
listModels(
) → Stream< ModelInfo> -
Returns all available models for this provider.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
validateApiKeyPresence(
) → void -
Throws if an API key is required but missing.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- defaultBaseUrl → Uri
-
Default base URL for the xAI API.
final
Constants
- defaultApiKeyName → const String
- Environment variable used to read the API key.
- defaultChatModel → const String
- Default chat model identifier.
- providerDisplayName → const String
- Human-friendly provider name.
- providerName → const String
- Canonical provider name.