Appam
API Reference

AppConfigBuilder

Fluent builder for constructing AppConfig programmatically.

Overview

AppConfigBuilder provides a fluent API for constructing AppConfig programmatically in Rust code, without requiring a TOML file. All fields are optional -- unset fields use their defaults.

Constructor

AppConfigBuilder::new() -> Self

Creates a new builder with all fields unset (defaults will apply on .build()).

use appam::config::AppConfigBuilder;

let builder = AppConfigBuilder::new();

Builder Methods

All methods consume and return Self, enabling method chaining.

OpenRouter Settings

MethodSignatureDescription
openrouter_api_key.openrouter_api_key(impl Into<String>) -> SelfSet the OpenRouter API key
openrouter_base_url.openrouter_base_url(impl Into<String>) -> SelfSet the OpenRouter base URL
model.model(impl Into<String>) -> SelfSet the default LLM model

Logging Settings

MethodSignatureDescription
logs_dir.logs_dir(impl Into<PathBuf>) -> SelfSet the logs directory
log_level.log_level(impl Into<String>) -> SelfSet log level (trace, debug, info, warn, error)
human_console.human_console(bool) -> SelfEnable/disable human-readable console output
log_format.log_format(LogFormat) -> SelfSet log file format (Plain, Json, Both)
enable_logs.enable_logs(bool) -> SelfEnable/disable framework logs (run-*.log, run-*.jsonl)
enable_traces.enable_traces(bool) -> SelfEnable/disable agent session traces (session-*.jsonl)
trace_format.trace_format(TraceFormat) -> SelfSet trace detail level (Compact, Detailed)

History Settings

MethodSignatureDescription
enable_history.enable_history(impl Into<PathBuf>) -> SelfEnable session history with the given database path
history_auto_save.history_auto_save(bool) -> SelfEnable/disable automatic session saving
history_max_sessions.history_max_sessions(usize) -> SelfSet maximum sessions to keep

Web Server Settings

MethodSignatureDescription
web_host.web_host(impl Into<String>) -> SelfSet the web server host address
web_port.web_port(u16) -> SelfSet the web server port
web_cors.web_cors(bool) -> SelfEnable/disable CORS
rate_limit_rpm.rate_limit_rpm(u64) -> SelfSet rate limit requests per minute
rate_limit_burst.rate_limit_burst(u32) -> SelfSet rate limit burst size

Build

.build() -> AppConfig

Consumes the builder and produces an AppConfig. Unset fields use their defaults. This method is infallible -- it always returns a valid configuration.

The resulting AppConfig uses the default LlmProvider and default provider configurations for OpenRouter, Anthropic, OpenAI, OpenAI Codex, and Vertex. To customize those providers, use TOML files or environment variables.

Examples

Minimal Configuration

use appam::config::AppConfigBuilder;

let config = AppConfigBuilder::new()
    .openrouter_api_key("sk-or-v1-...")
    .model("anthropic/claude-sonnet-4-5")
    .build();

Full Configuration

use appam::config::AppConfigBuilder;

let config = AppConfigBuilder::new()
    .openrouter_api_key("sk-or-v1-...")
    .model("openai/gpt-5")
    .logs_dir("./logs")
    .log_level("info")
    .human_console(true)
    .enable_logs(true)
    .enable_traces(true)
    .enable_history("./data/sessions.db")
    .history_auto_save(true)
    .history_max_sessions(100)
    .web_host("0.0.0.0")
    .web_port(8080)
    .web_cors(true)
    .rate_limit_rpm(60)
    .rate_limit_burst(10)
    .build();

Web Server Only

When any web-related method is called, a WebConfig is included in the output. If no web methods are called, config.web is None.

use appam::config::AppConfigBuilder;

let config = AppConfigBuilder::new()
    .web_host("127.0.0.1")
    .web_port(8080)
    .web_cors(false)
    .rate_limit_rpm(120)
    .rate_limit_burst(20)
    .build();

assert!(config.web.is_some());

See Also

  • AppConfig -- The configuration struct produced by this builder
  • AgentConfigBuilder -- Builder for agent-specific TOML configuration
  • AgentBuilder -- Builder for constructing agent instances directly