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

ParameterTypeDefaultDescription
api_keystrRequiredYour Aionvision API key
base_urlstrProduction APIAPI base URL
timeoutfloat300.0Request timeout in seconds
max_retriesint3Max retry attempts
retry_delayfloat1.0Initial retry delay (seconds)
polling_intervalfloat2.0Status poll interval
polling_timeoutfloat360.0Max polling wait time
tenant_idOptional[str]NoneTenant ID for multi-tenant deployments
proxy_urlOptional[str]NoneProxy URL (http, https, or socks5)
enable_tracingboolFalseOpenTelemetry tracing

Environment Variables

Use from_env() to load configuration from environment variables

from aion import AionVision
# Load all configuration from environment variables
async with AionVision.from_env() as client:
result = await client.upload_one("photo.jpg")
# Override specific values while using env vars for the rest
async 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 operations
async 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 operations
async 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 networks
async 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 exceeded
  • ServerError - 5xx server errors
  • AionvisionConnectionError - Network failures
  • AionvisionTimeoutError - Request timeouts

Per-Operation Overrides

Override config for specific operations

# Override polling timeout for this specific upload
result = await client.upload(
"large_image.jpg",
description_timeout=300.0 # 5 minute wait for this upload
)
# Override for batch wait
status = 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 values
print(f"Base URL: {config.base_url}")
print(f"Timeout: {config.timeout}s")
# Get the authorization header for custom HTTP requests
headers = 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).