pub struct Settings {Show 24 fields
pub version: u32,
pub thinking_level: ThinkingLevel,
pub theme: String,
pub default_model: Option<String>,
pub default_provider: Option<String>,
pub last_used_model: Option<String>,
pub last_used_provider: Option<String>,
pub max_tokens: Option<u32>,
pub temperature: Option<f32>,
pub default_temperature: Option<f64>,
pub max_response_tokens: Option<usize>,
pub session_history_size: usize,
pub session_dir: Option<PathBuf>,
pub stream_responses: bool,
pub extensions_enabled: bool,
pub auto_compaction: bool,
pub disabled_tools: Vec<String>,
pub tool_timeout_seconds: u64,
pub extensions: Vec<String>,
pub skills: Vec<String>,
pub prompts: Vec<String>,
pub themes: Vec<String>,
pub custom_providers: Vec<CustomProvider>,
pub dynamic_models: HashMap<String, Vec<String>>,
}Expand description
Application settings
Fields§
§version: u32Settings format version. Used for automatic migration.
thinking_level: ThinkingLevelThinking level for agent responses
theme: StringColor theme (e.g., “default”, “monokai”, “dracula”)
default_model: Option<String>Default model name without provider prefix (e.g., “claude-sonnet-4-20250514”)
default_provider: Option<String>Default provider to use (e.g., “anthropic”, “openai”)
last_used_model: Option<String>Last used model (automatically updated when user selects a model)
last_used_provider: Option<String>Last used provider (automatically updated when user selects a model)
max_tokens: Option<u32>Max tokens for responses
temperature: Option<f32>Temperature for generation (0.0–2.0)
default_temperature: Option<f64>Default temperature as f64 (higher precision, takes precedence over temperature)
max_response_tokens: Option<usize>Maximum tokens for generation (usize variant, takes precedence over max_tokens)
session_history_size: usizeSession history size (entries to keep in memory)
session_dir: Option<PathBuf>Directory for storing sessions (default: ~/.oxi/sessions)
stream_responses: boolWhether to stream responses
extensions_enabled: boolWhether extensions are enabled
auto_compaction: boolWhether to auto-compact conversations that exceed context window
disabled_tools: Vec<String>Built-in tools to disable (by name, e.g. ["web_search", "github_search"]).
All tools are enabled by default; list tools here to turn them off.
tool_timeout_seconds: u64Timeout in seconds for tool execution
extensions: Vec<String>List of extension paths or npm package sources to load
skills: Vec<String>List of skill paths or npm package sources to load
prompts: Vec<String>List of prompt template paths to load
themes: Vec<String>List of theme paths to load
custom_providers: Vec<CustomProvider>Registered custom providers (loaded from [[custom_provider]] TOML sections).
dynamic_models: HashMap<String, Vec<String>>Cached model lists fetched from provider /models endpoints.
Key is the provider name, value is a list of model IDs.
Updated when API keys are entered in setup wizard or on demand.
Implementations§
Source§impl Settings
impl Settings
Sourcepub fn settings_dir() -> Result<PathBuf, Error>
pub fn settings_dir() -> Result<PathBuf, Error>
Get the global settings directory path (~/.oxi).
Sourcepub fn settings_toml_path() -> Result<PathBuf, Error>
pub fn settings_toml_path() -> Result<PathBuf, Error>
Get the global settings TOML file path (~/.oxi/settings.toml).
Sourcepub fn settings_json_path() -> Result<PathBuf, Error>
pub fn settings_json_path() -> Result<PathBuf, Error>
Get the global settings JSON file path (~/.oxi/settings.json).
Sourcepub fn settings_path() -> Result<PathBuf, Error>
pub fn settings_path() -> Result<PathBuf, Error>
Get the global settings file path (JSON takes priority).
Returns the path to the settings file that should be used. If both JSON and TOML exist, JSON is returned (takes priority). If only one exists, that path is returned. If neither exists, returns the JSON path by default.
Sourcepub fn settings_path_with_preference(
prefer_json: bool,
) -> Result<PathBuf, Error>
pub fn settings_path_with_preference( prefer_json: bool, ) -> Result<PathBuf, Error>
Get the effective settings file path, preferring the specified format.
If prefer_json is true, checks JSON first; otherwise checks TOML first.
Returns the first existing file, or the preferred path if neither exists.
Sourcepub fn detect_format(path: &Path) -> SettingsFormat
pub fn detect_format(path: &Path) -> SettingsFormat
Detect the settings file format from its path.
Sourcepub fn find_project_settings(start_dir: &Path) -> Option<PathBuf>
pub fn find_project_settings(start_dir: &Path) -> Option<PathBuf>
Get the project-local settings file path.
Searches for .oxi/settings.json first, then .oxi/settings.toml.
Returns the first one found, or None if neither exists.
Sourcepub fn effective_session_dir(&self) -> Result<PathBuf, Error>
pub fn effective_session_dir(&self) -> Result<PathBuf, Error>
Resolve the effective session directory.
Priority: session_dir field → ~/.oxi/sessions.
Sourcepub fn load() -> Result<Settings, Error>
pub fn load() -> Result<Settings, Error>
Load settings, applying all layers:
- Built-in defaults
- Global
~/.oxi/settings.toml - Project
.oxi/settings.toml - Environment variable overrides
§Examples
use oxi_cli::Settings;
let settings = Settings::load().expect("Failed to load settings");
println!("Using model: {}", settings.effective_model(None));Sourcepub fn load_from(dir: &Path) -> Result<Settings, Error>
pub fn load_from(dir: &Path) -> Result<Settings, Error>
Load settings with an explicit working directory for project config discovery.
Sourcepub fn load_from_cwd() -> Result<Settings, Error>
pub fn load_from_cwd() -> Result<Settings, Error>
Convenience: load from current working directory.
Sourcepub fn apply_env(&mut self)
pub fn apply_env(&mut self)
Apply environment variable overrides in-place.
DEPRECATED: Environment variable overrides are being phased out in favor
of file-based configuration (~/.oxi/settings.toml). This method is
kept for CI/CD compatibility but should not be relied upon for local
development. Use oxi config set or oxi setup instead.
Supported variables (CI/CD only):
| Env var | Setting |
|---|---|
OXI_MODEL | default_model |
OXI_PROVIDER | default_provider |
OXI_THINKING | thinking_level |
OXI_THEME | theme |
OXI_MAX_TOKENS | max_tokens |
OXI_TEMPERATURE | default_temperature |
OXI_SESSION_DIR | session_dir |
OXI_STREAM | stream_responses |
OXI_EXTENSIONS_ENABLED | extensions_enabled |
OXI_AUTO_COMPACTION | auto_compaction |
OXI_TOOL_TIMEOUT | tool_timeout_seconds |
OXI_DISABLED_TOOLS | disabled_tools |
Sourcepub fn from_env() -> Settings
pub fn from_env() -> Settings
Build a Settings instance from only environment variables
(all other fields stay at defaults).
DEPRECATED: Returns defaults since env overrides are disabled.
Use Settings::load() to load from settings.toml instead.
Sourcepub fn save(&self) -> Result<(), Error>
pub fn save(&self) -> Result<(), Error>
Save settings to the global config file.
Uses the format of the existing file if present, otherwise saves as JSON. Preserves backward compatibility with existing TOML files.
Sourcepub fn save_to(&self, path: &Path) -> Result<(), Error>
pub fn save_to(&self, path: &Path) -> Result<(), Error>
Save settings to a specific path, using the format determined by the file extension.
Sourcepub fn save_project(&self, project_dir: &Path) -> Result<(), Error>
pub fn save_project(&self, project_dir: &Path) -> Result<(), Error>
Save settings to the project-local config file.
Uses the format of the existing file if present, otherwise saves as JSON.
Sourcepub fn serialize_for_format(
settings: &Settings,
format: SettingsFormat,
) -> Result<String, Error>
pub fn serialize_for_format( settings: &Settings, format: SettingsFormat, ) -> Result<String, Error>
Serialize settings to a string in the specified format.
Sourcepub fn parse_from_str(
content: &str,
format: SettingsFormat,
) -> Result<Settings, Error>
pub fn parse_from_str( content: &str, format: SettingsFormat, ) -> Result<Settings, Error>
Parse settings from a string in the specified format.
Sourcepub fn merge_cli(&mut self, model: Option<String>, provider: Option<String>)
pub fn merge_cli(&mut self, model: Option<String>, provider: Option<String>)
Merge with CLI arguments (CLI takes precedence).
Sourcepub fn effective_model(&self, cli_model: Option<&str>) -> Option<String>
pub fn effective_model(&self, cli_model: Option<&str>) -> Option<String>
Get the effective model ID (provider/model format).
Combines default_provider + default_model when both are set.
Returns None if no model is configured.
Sourcepub fn effective_provider(&self, cli_provider: Option<&str>) -> Option<String>
pub fn effective_provider(&self, cli_provider: Option<&str>) -> Option<String>
Get the effective provider. Returns None if no provider is configured.
Sourcepub fn effective_temperature(&self) -> Option<f64>
pub fn effective_temperature(&self) -> Option<f64>
Get the effective temperature, preferring default_temperature (f64)
over temperature (f32), falling back to None.
Sourcepub fn effective_max_tokens(&self) -> Option<usize>
pub fn effective_max_tokens(&self) -> Option<usize>
Get the effective max tokens, preferring max_response_tokens (usize)
over max_tokens (u32), falling back to None.
Sourcepub fn save_last_used(model_id: &str)
pub fn save_last_used(model_id: &str)
Save the last used model/provider and persist to disk.
Sourcepub fn save_theme(&mut self, name: &str) -> Result<(), Error>
pub fn save_theme(&mut self, name: &str) -> Result<(), Error>
Save the current theme to settings and persist to disk.
Sourcepub fn get_theme_name(&self) -> String
pub fn get_theme_name(&self) -> String
Get the theme name from settings, returning a default if not set.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Settings
impl<'de> Deserialize<'de> for Settings
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Settings, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Settings, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for Settings
impl Serialize for Settings
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for Settings
impl RefUnwindSafe for Settings
impl Send for Settings
impl Sync for Settings
impl Unpin for Settings
impl UnsafeUnpin for Settings
impl UnwindSafe for Settings
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
self file descriptor. Read moreSource§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more