Expand description
Exposed namespace of the module.
Structs§
- Batch
Processor - A client wrapper that supports batch processing of requests.
- Cached
Client - A client wrapper that caches chat completion responses.
- Chat
- Chat completions API accessor.
- Chat
Completion Chunk - Streaming chunk from chat completion.
- Chat
Completion Request - Request to create a chat completion.
- Chat
Completion Response - Response from chat completion request.
- Choice
- A single completion choice.
- Chunk
Choice - A single streaming choice.
- Circuit
Breaker - Circuit breaker for protecting against cascading failures.
- Circuit
Breaker Config - Circuit breaker configuration.
- Client
- XAI API client.
- Delta
- Incremental message update in streaming.
- Enhanced
Retry Config - Enhanced retry configuration with exponential backoff.
- Failover
Config - Failover configuration.
- Failover
Manager - Failover manager for multiple XAI endpoints.
- Function
- Function specification.
- Function
Call - Function call details.
- Health
Check Result - Result of a health check.
- List
Models Response - Response from listing all available models.
- Message
- A single message in a chat conversation.
- Metric
Guard - A wrapper that automatically records metrics for operations.
- Metrics
Collector - Metrics collector for XAI API operations.
- Model
- Information about a specific model.
- Models
- Models API accessor.
- Rate
Limiter - Token bucket rate limiter.
- Rate
Limiter Config - Rate limiter configuration using token bucket algorithm.
- Secret
- Secure wrapper for XAI API key.
- Sync
Cached Client - Synchronous wrapper for
cached_create(requirescachingfeature). - Sync
Client - A synchronous (blocking) wrapper around the async XAI client.
- Sync
Stream Iterator - Synchronous iterator wrapper around async streaming.
- Tool
- Tool definition for function calling.
- Tool
Call - Tool call made by the assistant.
- Tool
Result - Result of executing a tool call.
- Usage
- Token usage information for API requests.
- XaiEnvironment
Impl - Default implementation of XAI environment configuration.
Enums§
- Circuit
State - Circuit breaker states.
- Endpoint
Health - Endpoint health status.
- Health
Status - Health status of the API endpoint.
- Role
- Message role in a conversation.
- XaiError
- Error types for XAI API operations.
Constants§
- DEFAULT_
BASE_ URL - Default base URL for XAI API.
- DEFAULT_
TIMEOUT_ SECS - Default request timeout in seconds.
Traits§
- Client
ApiAccessors - Trait providing convenient API accessors for the client.
- XaiEnvironment
- Environment configuration trait for XAI API client.
Functions§
- count_
tokens - Counts tokens in a text string for a specific model.
- count_
tokens_ for_ request - Counts tokens in a chat completion request.
- create_
operation_ span - Creates a tracing span for tracking an API operation.
- execute_
tool_ calls_ parallel - Executes multiple tool calls in parallel.
- execute_
tool_ calls_ sequential - Executes multiple tool calls sequentially.
- health_
check - Performs a health check on the XAI API endpoint.
- liveness_
check - Performs a quick liveness check.
- readiness_
check - Performs a readiness check.
- sync_
count_ tokens - Synchronous wrapper for
count_tokens(requirescount_tokensfeature). - sync_
count_ tokens_ for_ request - Synchronous wrapper for
count_tokens_for_request(requirescount_tokensfeature). - sync_
validate_ request_ size - Synchronous wrapper for
validate_request_size(requirescount_tokensfeature). - to_curl
- Converts a chat completion request to a CURL command.
- to_
curl_ compact - Converts a chat completion request to a compact CURL command (single line).
- to_
curl_ with_ endpoint - Converts a chat completion request to a CURL command with custom endpoint.
- to_
curl_ with_ key - Converts a chat completion request to a CURL command with a custom API key.
- validate_
frequency_ penalty - Validates that
frequency_penaltyis within valid range [-2.0, 2.0]. - validate_
max_ tokens - Validates that
max_tokensis positive. - validate_
messages - Validates that messages array is non-empty with valid content.
- validate_
model - Validates that the model name is supported.
- validate_
presence_ penalty - Validates that
presence_penaltyis within valid range [-2.0, 2.0]. - validate_
request - Validates a chat completion request.
- validate_
request_ size - Validates that a request fits within the model’s context window.
- validate_
temperature - Validates that temperature is within valid range [0.0, 2.0].
- validate_
tools - Validates tool definitions (function calling schemas).
- validate_
top_ p - Validates that
top_pis within valid range [0.0, 1.0].
Type Aliases§
- Result
- Result type alias using
error_tools.