> ## Documentation Index
> Fetch the complete documentation index at: https://docs.galileo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# configuration

## ConfigKey

Metadata for a configuration key.

Defines a single configuration option with its properties, validation rules,
and relationship to environment variables. Used by the ConfigurationMeta
metaclass to enable dynamic attribute access.

**Arguments**

* `name` (`str`): The attribute name used in the Configuration class (e.g., "galileo\_api\_key").

* `env_var` (`str`): The corresponding environment variable name (e.g., "GALILEO\_API\_KEY").

* `description` (`str`): Human-readable description of the configuration key's purpose.

* `required` (`bool`): Whether this key must be set for the configuration to be considered complete.
  Default: False.

* `sensitive` (`bool`): Whether this key contains sensitive information (e.g., API keys, passwords).
  Sensitive values are masked in get\_configuration() output. Default: False.

* `default` (`Any`): The default value if no explicit value or environment variable is set.
  Default: None.

* `value_type` (`type`): The expected Python type for this configuration value. Default: str.

* `parser` (`Optional[Callable[[str], Any]]`): Optional function to convert string values from environment variables
  to the appropriate type. Default: None (no conversion).

## ConfigurationMeta

Metaclass for dynamic attribute handling based on CONFIGURATION\_KEYS.

This metaclass enables the Configuration class to provide dynamic attribute access
with automatic resolution from multiple sources. When accessing a configuration
attribute (e.g., `Configuration.galileo_api_key`), the metaclass:

1. Checks if the attribute is in \_CONFIGURATION\_KEYS
2. Resolves the value from: explicit value → environment variable → .env file → default
3. Applies type conversion and validation if a parser is defined
4. Returns the resolved value

When setting a configuration attribute (e.g., `Configuration.galileo_api_key = "key"`),
the metaclass:

1. Stores the value internally (with underscore prefix: `_galileo_api_key`)
2. Automatically updates the corresponding environment variable
3. Ensures compatibility with libraries that read from os.environ

This pattern provides:

* Extensibility: New configuration keys can be added to \_CONFIGURATION\_KEYS
* Consistency: All configuration uses the same resolution pattern
* Compatibility: Environment variables are kept in sync for third-party libraries
* Transparency: Configuration sources are clearly prioritized

Reference: [https://docs.python.org/3/reference/datamodel.html#customizing-attribute-access](https://docs.python.org/3/reference/datamodel.html#customizing-attribute-access)

## Configuration

Single source of truth for SDK configuration.

This class uses a metaclass pattern to provide dynamic attribute access to configuration
keys defined in \_CONFIGURATION\_KEYS. Each configuration key can be accessed as a class
attribute, with values resolved in the following priority order:

1. Explicitly set value (via `Configuration.key = value`)
2. Environment variable (e.g., GALILEO\_API\_KEY)
3. .env file (loaded automatically on first access)
4. Default value (defined in the key configuration)

The metaclass automatically:

* Syncs attribute assignments to environment variables
* Loads .env files on first configuration access
* Provides type conversion and validation via parsers

**Arguments**

* `Configuration attributes are dynamically provided based on _CONFIGURATION_KEYS`: galileo\_api\_key (str): API key for Galileo authentication (sensitive)
  console\_url (str): URL of the Galileo console
  openai\_api\_key (str): OpenAI API key for SDK interoperability (sensitive)
  default\_project\_name (str): Default project name
  default\_project\_id (str): Default project ID
  default\_logstream\_name (str): Default log stream name
  default\_logstream\_id (str): Default log stream ID
  logging\_disabled (bool): Disable all telemetry logging to Galileo
  log\_level (str): Python logging level for SDK console output

**Examples**

Reading configuration values:

```python theme={null}
# Access via class attribute (reads from env vars, .env, or defaults)
api_key = Configuration.galileo_api_key
url = Configuration.console_url
```

Setting configuration values:

```python theme={null}
# Set explicitly (also updates environment variables)
Configuration.galileo_api_key = "your-api-key"
Configuration.console_url = "https://console.galileo.ai"
```

Checking and connecting:

```python theme={null}
# Check if required configuration is present
if Configuration.is_configured():
    Configuration.connect()
```

Getting all configuration:

```python theme={null}
# Get all configuration values (sensitive values are masked)
config = Configuration.get_configuration()
print(config["galileo_api_key"])  # Output: "***"
print(config["console_url"])       # Output: actual URL
```

Resetting configuration:

```python theme={null}
# Clear all configuration values and environment variables
Configuration.reset()
```

Configuring console logging:

```python theme={null}
# Enable console logging for debugging
Configuration.enable_console_logging()  # INFO level by default
Configuration.enable_console_logging("DEBUG")  # Verbose output

# Disable console logging
Configuration.disable_console_logging()
```

**Notes**

* The Configuration class should not be instantiated; use it as a static class
* Direct attribute access (e.g., `Configuration.galileo_api_key`) is the recommended pattern
* The `get_configuration()` method masks sensitive values for safe display/logging
* Setting an attribute automatically updates the corresponding environment variable
* This design maintains compatibility with third-party libraries expecting env vars

### connect

```python theme={null}
def connect(cls) -> None
```

Validate configuration and connect to Galileo.

### disable\_console\_logging

```python theme={null}
def disable_console_logging(cls) -> None
```

Disable console logging for SDK output.

This restores the SDK to its default silent behavior where no
log messages are printed to the console.

**Examples**

```python theme={null}
Configuration.disable_console_logging()
```

### enable\_console\_logging

```python theme={null}
def enable_console_logging(cls, level: str | None=None) -> None
```

Enable console logging for SDK output.

This is useful for debugging and interactive use (REPL, Jupyter, etc.)
to see SDK progress and diagnostic information.

**Arguments**

* `level` (`Optional[str]`): Logging level as string: "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL".
  If not provided, uses Configuration.log\_level or defaults to "INFO".

**Examples**

```python theme={null}
# Enable with default INFO level
Configuration.enable_console_logging()

# Enable with DEBUG level for verbose output
Configuration.enable_console_logging("DEBUG")

# Or set via configuration and enable
Configuration.log_level = "DEBUG"
Configuration.enable_console_logging()
```

### get\_configuration

```python theme={null}
def get_configuration(cls) -> dict[str, Any]
```

Get all configuration values (sensitive values are masked).

### is\_configured

```python theme={null}
def is_configured(cls) -> bool
```

Check if all required configuration keys are set.

### reset

```python theme={null}
def reset(cls) -> None
```

Reset all configuration values and clear environment variables.

## parse\_log\_level

```python theme={null}
def parse_log_level(value: str) -> str
```

Parse and validate a log level string; returns uppercase level name.
