Documentation
Configuration
Customize client behavior with configuration options
Client Initialization
All available configuration parameters
from scopix import Scopix
client = Scopix( api_key="scopix_...", # Required: Your API key base_url="https://api.scopix.ai/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 or https) enable_tracing=False, # OpenTelemetry tracing)Configuration Options
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | str | Required | Your Scopix 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 or https) |
enable_tracing | bool | False | OpenTelemetry tracing |
Environment Variables
Use from_env() to load configuration from environment variables
from scopix import Scopix
# Load all configuration from environment variablesasync with Scopix.from_env() as client: result = await client.files.upload("photo.jpg")
# Override specific values while using env vars for the restasync with Scopix.from_env(timeout=60.0) as client: result = await client.files.upload("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 Scopix( 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.files.upload("photo.jpg")
# For large batch operationsasync with Scopix( 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.files.upload_batch("/path/to/photos")Retry Configuration
Configure automatic retry behavior
# Aggressive retries for unreliable networksasync with Scopix( api_key=api_key, max_retries=5, # More retry attempts retry_delay=0.5, # Start with 0.5s delay) as client: result = await client.files.upload("photo.jpg")
# No retries (fail fast)async with Scopix( api_key=api_key, max_retries=0, # No automatic retries) as client: result = await client.files.upload("photo.jpg")The SDK uses exponential backoff: delays double with each retry, starting from retry_delay (default 1s).
Retryable Errors
These errors trigger automatic retries
RateLimitError- API rate limit exceededServerError- 5xx server errorsScopixConnectionError- Network failuresasyncio.TimeoutError- Request timeouts
Post-Upload Description Polling
client.files.upload() returns as soon as the bytes are in storage; AI descriptions complete asynchronously. Poll for completion:
result = await client.files.upload("large_image.jpg")# Wait for description to finish (or fail)status = await client.files.get_processing_status(result.file_id)while not status.is_terminal: await asyncio.sleep(2) status = await client.files.get_processing_status(result.file_id)API Key Validation
The SDK validates API key format on initialization
from scopix import Scopix
try: client = Scopix(api_key="invalid_key")except ValueError as e: print(f"Invalid API key: {e}") # API key must match format: scopix_...ClientConfig Class
Configuration as a standalone object. ClientConfig supports advanced options not available via the Scopix() constructor. The constructor accepts only the 10 basic parameters (api_key, base_url, timeout, max_retries, retry_delay, polling_interval, polling_timeout, tenant_id, proxy_url, enable_tracing); advanced settings such as circuit breaker, logging, and tracing options must be configured by constructing a ClientConfig object directly.
from scopix import ClientConfig
config = ClientConfig( api_key="scopix_...", base_url="https://api.scopix.ai/api/v2", timeout=300.0, max_retries=3, retry_delay=1.0, polling_interval=2.0, polling_timeout=360.0,
# Also available in Scopix() constructor: tenant_id=None, # Tenant ID for multi-tenant deployments proxy_url=None, # Proxy URL (http or https)
# Advanced options (only configurable via ClientConfig, not via Scopix() constructor) enable_logging=True, # Structured logging for HTTP requests)
# 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 scopix_..."}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).

