pub struct ClaudeSettings {
pub env: BTreeMap<String, String>,
pub other: BTreeMap<String, Value>,
}Expand description
Claude settings manager for API configuration
Manages the Claude settings.json file to control Claude’s API configuration Handles environment variables and preserves other settings
Fields§
§env: BTreeMap<String, String>Environment variables map (ANTHROPIC_AUTH_TOKEN, ANTHROPIC_BASE_URL, ANTHROPIC_MODEL, ANTHROPIC_SMALL_FAST_MODEL)
other: BTreeMap<String, Value>Other settings to preserve when modifying API configuration
Implementations§
Source§impl ClaudeSettings
impl ClaudeSettings
Sourcepub fn load(custom_dir: Option<&str>) -> Result<Self>
pub fn load(custom_dir: Option<&str>) -> Result<Self>
Load Claude settings from disk
Reads the JSON file from the configured Claude settings directory Returns default empty settings if file doesn’t exist Creates the file with default structure if it doesn’t exist
§Arguments
custom_dir- Optional custom directory for Claude settings
§Errors
Returns error if file exists but cannot be read or parsed
Sourcepub fn save(&self, custom_dir: Option<&str>) -> Result<()>
pub fn save(&self, custom_dir: Option<&str>) -> Result<()>
Save Claude settings to disk
Writes the current state to the configured Claude settings directory Creates the directory structure if it doesn’t exist Ensures the env field is properly serialized
§Arguments
custom_dir- Optional custom directory for Claude settings
§Errors
Returns error if directory cannot be created or file cannot be written
Sourcepub fn switch_to_config(&mut self, config: &Configuration)
pub fn switch_to_config(&mut self, config: &Configuration)
Switch to a specific API configuration
Updates the environment variables with the provided configuration Ensures env field exists before updating
§Arguments
config- Configuration containing token, URL, and optional model settings to apply
Sourcepub fn remove_anthropic_env(&mut self)
pub fn remove_anthropic_env(&mut self)
Remove Anthropic environment variables
Clears all Anthropic-related environment variables from settings Used to reset to default Claude behavior
Trait Implementations§
Source§impl Clone for ClaudeSettings
impl Clone for ClaudeSettings
Source§fn clone(&self) -> ClaudeSettings
fn clone(&self) -> ClaudeSettings
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more