Overview
The Config API provides a centralized way to manage Strix configuration through environment variables and persistent settings.
Config Class
Main configuration manager for Strix.
Class Variables
Configuration defaults stored as class attributes:
Reasoning effort: “low”, “medium”, or “high”
Request timeout in seconds
strix_image
str
default:"'ghcr.io/usestrix/strix-sandbox:0.1.12'"
Docker image for sandboxes
Runtime backend (currently only “docker”)
strix_sandbox_execution_timeout
Tool execution timeout in seconds
Methods
get
@classmethod
def get(cls, name: str) -> str | None
Gets a configuration value from environment or defaults.
Configuration key in lowercase (e.g., “strix_llm”)
Configuration value or None
Example:
from strix.config import Config
model = Config.get("strix_llm")
print(f"Using model: {model}")
image = Config.get("strix_image")
print(f"Sandbox image: {image}")
config_dir
@classmethod
def config_dir(cls) -> Path
Returns the configuration directory path.
Path to ~/.strix directory
Example:
from strix.config import Config
config_path = Config.config_dir()
print(f"Config stored in: {config_path}")
config_file
@classmethod
def config_file(cls) -> Path
Returns the configuration file path.
Path to ~/.strix/cli-config.json
load
@classmethod
def load(cls) -> dict[str, Any]
Loads configuration from the config file.
Example:
from strix.config import Config
config = Config.load()
print(f"Saved environment variables: {config.get('env', {})}")
save
@classmethod
def save(cls, config: dict[str, Any]) -> bool
Saves configuration to the config file.
Configuration dictionary to save
True if successful, False otherwise
Example:
from strix.config import Config
config_data = {
"env": {
"STRIX_LLM": "claude-3-5-sonnet-20241022",
"LLM_API_KEY": "sk-ant-..."
}
}
success = Config.save(config_data)
if success:
print("Configuration saved")
apply_saved
@classmethod
def apply_saved(cls, force: bool = False) -> dict[str, str]
Applies saved configuration to environment variables.
Force apply even if environment variables are already set
Dictionary of applied environment variables
Example:
from strix.config import Config
# Apply saved config
applied = Config.apply_saved()
print(f"Applied variables: {list(applied.keys())}")
# Force apply
applied = Config.apply_saved(force=True)
save_current
@classmethod
def save_current(cls) -> bool
Saves current environment variables to the config file.
Example:
import os
from strix.config import Config
# Set environment variables
os.environ["STRIX_LLM"] = "gpt-4o"
os.environ["LLM_API_KEY"] = "sk-..."
# Save to config
Config.save_current()
tracked_vars
@classmethod
def tracked_vars(cls) -> list[str]
Returns list of tracked environment variable names.
List of uppercase environment variable names
Example:
from strix.config import Config
tracked = Config.tracked_vars()
print(f"Tracked variables: {tracked}")
# Output: ['STRIX_LLM', 'LLM_API_KEY', 'LLM_API_BASE', ...]
Helper Functions
apply_saved_config
from strix.config import apply_saved_config
applied = apply_saved_config(force: bool = False) -> dict[str, str]
Applies saved configuration to environment.
save_current_config
from strix.config import save_current_config
success = save_current_config() -> bool
Saves current environment to config file.
resolve_llm_config
from strix.config import resolve_llm_config
model, api_key, api_base = resolve_llm_config() -> tuple[str | None, str | None, str | None]
Resolves LLM configuration from environment.
return
tuple[str | None, str | None, str | None]
Tuple of (model_name, api_key, api_base)
Example:
from strix.config import resolve_llm_config
model, api_key, api_base = resolve_llm_config()
if model:
print(f"Model: {model}")
print(f"API Base: {api_base or 'default'}")
else:
print("No LLM configured")
The config file is stored at ~/.strix/cli-config.json:
{
"env": {
"STRIX_LLM": "claude-3-5-sonnet-20241022",
"LLM_API_KEY": "sk-ant-...",
"STRIX_IMAGE": "ghcr.io/usestrix/strix-sandbox:0.1.12",
"STRIX_RUNTIME_BACKEND": "docker"
}
}
Environment Variables
LLM Configuration
Model name (e.g., “claude-3-5-sonnet-20241022”)
Reasoning effort for o1 models: “low”, “medium”, “high”
STRIX_MEMORY_COMPRESSOR_TIMEOUT
Memory compression timeout in seconds
Request timeout in seconds
Runtime Configuration
STRIX_IMAGE
str
default:"'ghcr.io/usestrix/strix-sandbox:0.1.12'"
Docker image for sandboxes
STRIX_SANDBOX_EXECUTION_TIMEOUT
Tool execution timeout in seconds
STRIX_SANDBOX_CONNECT_TIMEOUT
Connection timeout in seconds
Feature Configuration
API key for Perplexity web search
Enable telemetry (1 or 0)
Usage Examples
Basic Configuration
import os
from strix.config import Config
# Set environment variables
os.environ["STRIX_LLM"] = "claude-3-5-sonnet-20241022"
os.environ["LLM_API_KEY"] = "sk-ant-..."
# Get configuration values
model = Config.get("strix_llm")
api_key = Config.get("llm_api_key")
print(f"Model: {model}")
print(f"API Key: {api_key[:10]}...")
Persistent Configuration
import os
from strix.config import Config
# Set configuration
os.environ["STRIX_LLM"] = "gpt-4o"
os.environ["LLM_API_KEY"] = "sk-..."
os.environ["STRIX_IMAGE"] = "ghcr.io/usestrix/strix-sandbox:latest"
# Save to file
Config.save_current()
print("Configuration saved to ~/.strix/cli-config.json")
# Later, in another session
from strix.config import apply_saved_config
# Load saved configuration
applied = apply_saved_config()
print(f"Applied {len(applied)} variables from saved config")
Custom Configuration File
from pathlib import Path
from strix.config import Config
# Use custom config file
Config._config_file_override = Path("/custom/path/config.json")
# Load from custom location
config = Config.load()
print(f"Loaded config from custom path: {config}")
Checking Configuration
from strix.config import Config, resolve_llm_config
# Check what's configured
model, api_key, api_base = resolve_llm_config()
if not model:
print("ERROR: STRIX_LLM not configured")
else:
print(f"Model: {model}")
print(f"API Base: {api_base or 'default'}")
print(f"Has API Key: {bool(api_key)}")
# List all tracked variables
tracked = Config.tracked_vars()
print(f"\nTracked variables ({len(tracked)}):")
for var in tracked:
value = os.environ.get(var)
if value:
display = value[:20] + "..." if len(value) > 20 else value
print(f" {var}: {display}")