Skip to main content

synth_ai.core.config.base

Base configuration classes for Synth AI SDK. This module defines the base config class that all job configs inherit from, ensuring consistent handling of common fields like API keys and backend URLs.

Classes

BaseJobConfig

Base class for all job configuration dataclasses. This class provides common functionality shared across all job types (prompt learning, SFT, RL, research agent). Subclasses should inherit from this and add job-specific fields. The base class ensures consistent handling of:
  • Backend URL resolution
  • API key validation
  • Common configuration patterns
Methods:

resolve_credentials

resolve_credentials(self) -> tuple[str, str]
Resolve API key and backend URL. Uses provided values or falls back to environment resolution. Returns:
  • Tuple of (backend_url, api_key)
Raises:
  • ConfigError: If required credentials cannot be resolved

validate

validate(self) -> list[str]
Validate the configuration. Returns:
  • List of validation error messages (empty if valid)

ConfigValidator

Base class for configuration validators. Validators provide a way to validate and normalize configuration before it’s used to create jobs. This is useful for:
  • Type checking
  • Value validation
  • Default value injection
  • Cross-field validation
Subclasses should implement the validate() method to perform job-specific validation logic. Methods:

require_field

require_field(config: dict[str, Any], field_name: str, field_type: type | tuple[type, ...] | None = None) -> Any
Require a field to be present in config. Args:
  • config: Configuration dict
  • field_name: Name of required field
  • field_type: Optional type(s) to validate against
Returns:
  • The field value
Raises:
  • ConfigError: If field is missing or wrong type

validate_positive

validate_positive(value: int | float, field_name: str) -> None
Validate that a numeric value is positive. Args:
  • value: Value to check
  • field_name: Name for error message
Raises:
  • ConfigError: If value is not positive