Skip to content

Configuration

The MicroDC client can be configured via environment variables, a configuration file, or programmatically.

Environment Variables

MICRODC_API_KEY=mDC_499FC19C-686A-47C5-AA93-E619C55EBE98
MICRODC_BASE_URL=https://api.microdc.ai
MICRODC_TIMEOUT=30
MICRODC_POLL_INTERVAL=2.0
MICRODC_VERIFY_SSL=true
MICRODC_AUTO_POLLING=true
MICRODC_ENCRYPTION_KEY_PATH=~/.microdc/keys
Variable Default Description
MICRODC_API_KEY (required) API key for authentication
MICRODC_BASE_URL https://api.microdc.ai Base URL for the API
MICRODC_TIMEOUT 30 Request timeout in seconds
MICRODC_POLL_INTERVAL 2.0 Polling interval in seconds
MICRODC_VERIFY_SSL true Enable SSL verification
MICRODC_AUTO_POLLING true Start the background polling thread
MICRODC_ENCRYPTION_KEY_PATH ~/.microdc/keys Directory for RSA encryption keys

These are read by Config, not by Client

Client(...) does not consult the environment on its own. Use Config.from_env() / Config.load() and pass the values to the constructor — see Programmatic Configuration.

Configuration File

Create a .microdc.json file in your project root:

{
    "api_key": "mDC_499FC19C-686A-47C5-AA93-E619C55EBE98",
    "base_url": "https://api.microdc.ai",
    "timeout": 30,
    "poll_interval": 2.0,
    "default_model": "llama3.3",
    "default_priority": 10
}

Warning

Do not commit .microdc.json to version control if it contains your API key. Add it to .gitignore.

Programmatic Configuration

Config gathers settings from a file, the environment, or explicit values. The Client does not read it automatically — load the config, then pass the fields you want to the constructor:

from microdc import Client, Config

# Config.load() checks ./.microdc.json first, then falls back to MICRODC_* env vars
config = Config.load()
config.validate()

client = Client(
    api_key=config.api_key,
    base_url=config.base_url,
    timeout=config.timeout,
    verify_ssl=config.verify_ssl,
    auto_start_polling=config.auto_start_polling,
    encryption_key_path=config.encryption_key_path,
)

Other entry points:

Config.from_env()                  # environment variables only
Config.from_file(".microdc.json")  # a specific file (raises if missing)
Config(api_key="mDC_...", timeout=60)  # explicit values

Not every Config field is wired up yet

poll_interval, max_retries, retry_backoff, and default_model are stored on Config but are not yet consumed by Client. Polling is fixed at 2.0s and retry behaviour is fixed at the module defaults in microdc/core/http.py. A Client.from_config() constructor is on the roadmap.

Client Constructor Options

client = Client(
    api_key="mDC_...",                  # Required: API key
    base_url="https://api.microdc.ai",  # API endpoint
    timeout=30,                         # Request timeout (seconds)
    verify_ssl=True,                    # SSL certificate verification
    auto_start_polling=True,            # Auto-start background polling
    encryption_key_path=None,           # Custom RSA key directory
)
Parameter Type Default Description
api_key str (required) API key starting with mDC_
base_url str https://api.microdc.ai API base URL
timeout int 30 Request timeout in seconds
verify_ssl bool True Verify SSL certificates
auto_start_polling bool True Start polling on init
encryption_key_path Optional[str] None RSA key directory (defaults to ~/.microdc/keys/)

Configuration Precedence

Client() only ever uses its own arguments and its built-in defaults. When you resolve settings through Config.load(), that helper applies this order:

  1. Configuration file -- an explicit path, else ./.microdc.json if it exists
  2. Environment variables -- MICRODC_* variables, when no file was found
  3. Defaults -- built-in default values

Polling Configuration

The client uses background polling to check job status:

# Default: background thread polls every 2 seconds
client = Client(api_key="mDC_...")

# Disable auto-polling (manual control via wait_for_job / wait_for_all)
client = Client(api_key="mDC_...", auto_start_polling=False)

Retry Configuration

The client automatically retries failed requests. These values are module constants in microdc/core/http.py and are not currently configurable per client:

  • Retry attempts: 3
  • Base delay: 1 second
  • Backoff multiplier: 2.0 (exponential)
  • Retryable status codes: 408, 429, 500, 502, 503, 504