Documentation
Configuration
Customize client behavior with configuration options
Client Initialization
All available configuration parameters
from aion import AionVision
client = AionVision( api_key="aion_...", # Required: Your API key base_url="https://api.aionvision.tech/api/v2", # API base URL timeout=300.0, # Request timeout (seconds) max_retries=3, # Retry attempts for transient failures retry_delay=1.0, # Initial retry delay (exponential backoff) polling_interval=2.0, # Status check interval (seconds) polling_timeout=360.0, # Max wait for async operations tenant_id=None, # Tenant ID for multi-tenant deployments proxy_url=None, # Proxy URL (http, https, or socks5) enable_tracing=False, # OpenTelemetry tracing)Configuration Options
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | str | Required | Your Aionvision API key |
base_url | str | Production API | API base URL |
timeout | float | 300.0 | Request timeout in seconds |
max_retries | int | 3 | Max retry attempts |
retry_delay | float | 1.0 | Initial retry delay (seconds) |
polling_interval | float | 2.0 | Status poll interval |
polling_timeout | float | 360.0 | Max polling wait time |
tenant_id | Optional[str] | None | Tenant ID for multi-tenant deployments |
proxy_url | Optional[str] | None | Proxy URL (http, https, or socks5) |
enable_tracing | bool | False | OpenTelemetry tracing |
Environment Variables
Use from_env() to load configuration from environment variables
from aion import AionVision
# Load all configuration from environment variablesasync with AionVision.from_env() as client: result = await client.upload_one("photo.jpg")
# Override specific values while using env vars for the restasync with AionVision.from_env(timeout=60.0) as client: result = await client.upload_one("photo.jpg")See the Environment Variables Reference for a complete list of supported environment variables and .env file usage.
Timeout Configuration
Adjust timeouts for different scenarios
# For fast operationsasync with AionVision( api_key=api_key, timeout=30.0, # 30 second request timeout polling_timeout=60.0, # 1 minute max wait for async ops) as client: result = await client.upload_one("photo.jpg")
# For large batch operationsasync with AionVision( api_key=api_key, timeout=600.0, # 10 minute request timeout polling_timeout=3600.0, # 1 hour max wait for batch completion polling_interval=10.0, # Check every 10 seconds) as client: results = await client.upload("/path/to/photos")Retry Configuration
Configure automatic retry behavior
# Aggressive retries for unreliable networksasync with AionVision( api_key=api_key, max_retries=5, # More retry attempts retry_delay=0.5, # Start with 0.5s delay) as client: result = await client.upload_one("photo.jpg")
# No retries (fail fast)async with AionVision( api_key=api_key, max_retries=0, # No automatic retries) as client: result = await client.upload_one("photo.jpg")The SDK uses exponential backoff: delays double with each retry (0.5s → 1s → 2s → 4s...)
Retryable Errors
These errors trigger automatic retries
RateLimitError- API rate limit exceededServerError- 5xx server errorsAionvisionConnectionError- Network failuresAionvisionTimeoutError- Request timeouts
Per-Operation Overrides
Override config for specific operations
# Override polling timeout for this specific uploadresult = await client.upload( "large_image.jpg", description_timeout=300.0 # 5 minute wait for this upload)
# Override for batch waitstatus = await client.batch.wait_for_completion( batch_id="...", timeout=600.0, # 10 minute wait poll_interval=5.0, # Check every 5 seconds)API Key Validation
The SDK validates API key format on initialization
from aion import AionVision
try: client = AionVision(api_key="invalid_key")except ValueError as e: print(f"Invalid API key: {e}") # API key must match format: aion_...ClientConfig Class
Configuration as a standalone object. ClientConfig supports additional advanced options beyond what the AionVision() constructor exposes.
from aion import ClientConfig
config = ClientConfig( api_key="aion_...", base_url="https://api.aionvision.tech/api/v2", timeout=300.0, max_retries=3, retry_delay=1.0, polling_interval=2.0, polling_timeout=360.0,
# Advanced options (also available via AionVision() constructor) tenant_id=None, # Tenant ID for multi-tenant deployments proxy_url=None, # Proxy URL (http, https, or socks5) circuit_breaker_enabled=True, # Enable circuit breaker for resilience circuit_breaker_failure_threshold=5, # Failures before opening circuit circuit_breaker_success_threshold=2, # Successes to close circuit circuit_breaker_timeout=30.0, # Seconds before attempting recovery enable_logging=True, # Structured logging for HTTP requests enable_tracing=False, # OpenTelemetry tracing tracing_service_name="aionvision-sdk", # Service name for tracing spans propagate_trace_context=True, # Send W3C traceparent headers send_correlation_id=True, # Send X-Correlation-ID header send_request_id=True, # Send X-Request-ID header)
# Access configuration valuesprint(f"Base URL: {config.base_url}")print(f"Timeout: {config.timeout}s")
# Get the authorization header for custom HTTP requestsheaders = config.auth_header # {"Authorization": "Bearer aion_..."}HTTPS Required
The SDK enforces HTTPS for all API communication. Non-HTTPS base_url values will raise a ValueError on initialization (localhost URLs are exempt for development).