venice_ai.presets.production
Production configuration preset for Venice AI SDK.
This preset provides battle-tested configuration optimized for production deployments with enterprise-grade features including:
- Redis backend for distributed state management
- Intelligent scheduler with rate limiting
- Circuit breaker protection
- Optimized connection pooling
- Conservative timeouts for reliability
create_production_config
def create_production_config(
redis_url: str | None = None,
redis_key_prefix: str = "venice:prod:",
max_concurrent_executions: int = 100,
max_queue_size: int = 5000,
enable_metrics: bool = True,
_allow_localhost_for_testing: bool = False) -> VeniceAIConfig
Create a production-optimized configuration.
This configuration is designed for production deployments and includes:
- Redis backend for distributed state across multiple instances
- Intelligent scheduler with automatic rate limit discovery
- Circuit breaker with conservative thresholds
- Connection pooling optimized for high throughput
- Retry logic with exponential backoff
Arguments:
redis_url- Redis connection URL. REQUIRED for production use. Set via VENICE_REDIS_URL environment variable or pass explicitly.Example- redis://user:pass@prod-redis:6379/0 CRITICAL: Using localhost in production will cause failures in distributed/multi-instance environments.redis_key_prefix- Prefix for all Redis keys to avoid collisions (default: venice:prod:)max_concurrent_executions- Maximum concurrent requests (default: 100)max_queue_size- Maximum queue size before rejecting requests (default: 5000)enable_metrics- Enable metrics collection (default: True)
Returns:
VeniceAIConfig configured for production use
Raises:
ValueError- If redis_url is not provided via parameter or VENICE_REDIS_URL environment variable
Example:
>>> import os
>>> os.environ['VENICE_REDIS_URL'] = 'redis://prod-redis:6379'
>>> from venice_ai.presets import create_production_config
>>> from venice_ai import VeniceClient
>>>
>>> config = create_production_config(
... max_concurrent_executions=200
... )
>>> client = VeniceClient(config=config, api_key="your-key")
Best Practices:
- ALWAYS set VENICE_REDIS_URL environment variable in production
- Use a dedicated Redis instance for production
- Monitor Redis connection pool metrics
- Adjust max_concurrent_executions based on your rate limits
- Enable metrics for production observability
- Use separate Redis key prefixes for different environments
create_production_config_high_throughput
def create_production_config_high_throughput(
redis_url: str | None = None,
redis_key_prefix: str = "venice:prod:",
_allow_localhost_for_testing: bool = False) -> VeniceAIConfig
Create a high-throughput production configuration.
Optimized for maximum throughput when you have high rate limits. Uses more aggressive settings than standard production config.
Arguments:
redis_url- Redis connection URL. REQUIRED for production use. Set via VENICE_REDIS_URL environment variable or pass explicitly. CRITICAL: Using localhost in production will cause failures in distributed/multi-instance environments.redis_key_prefix- Prefix for Redis keys
Returns:
VeniceAIConfig optimized for high throughput
Raises:
ValueError- If redis_url is not provided via parameter or VENICE_REDIS_URL environment variable
Warnings:
Only use this preset if you have sufficient rate limits and infrastructure to handle high concurrency.
create_production_config_conservative
def create_production_config_conservative(
redis_url: str | None = None,
redis_key_prefix: str = "venice:prod:",
_allow_localhost_for_testing: bool = False) -> VeniceAIConfig
Create a conservative production configuration.
Optimized for maximum reliability over throughput. Use this when stability is more important than speed.
Arguments:
redis_url- Redis connection URL. REQUIRED for production use. Set via VENICE_REDIS_URL environment variable or pass explicitly. CRITICAL: Using localhost in production will cause failures in distributed/multi-instance environments.redis_key_prefix- Prefix for Redis keys
Returns:
VeniceAIConfig optimized for reliability
Raises:
ValueError- If redis_url is not provided via parameter or VENICE_REDIS_URL environment variable