pub struct ConfigBuilder { /* private fields */ }Expand description
Fluent builder for Config.
Implementations§
Source§impl ConfigBuilder
impl ConfigBuilder
Sourcepub fn apply_profile(self, p: &ConfigProfile) -> Self
pub fn apply_profile(self, p: &ConfigProfile) -> Self
Apply the set fields of a ConfigProfile over the current builder.
Source§impl ConfigBuilder
impl ConfigBuilder
Sourcepub fn base_url(self, url: impl Into<String>) -> Self
pub fn base_url(self, url: impl Into<String>) -> Self
Set the OpenAI-compatible base URL (defaults to OpenRouter).
Sourcepub fn api_key_env(self, var: impl Into<String>) -> Self
pub fn api_key_env(self, var: impl Into<String>) -> Self
Change which environment variable the key is read from.
Sourcepub fn system_prompt(self, prompt: impl Into<String>) -> Self
pub fn system_prompt(self, prompt: impl Into<String>) -> Self
Replace the system prompt.
Sourcepub fn temperature(self, t: f32) -> Self
pub fn temperature(self, t: f32) -> Self
Set the sampling temperature.
Sourcepub fn max_tokens(self, n: u32) -> Self
pub fn max_tokens(self, n: u32) -> Self
Set the max output tokens.
Sourcepub fn max_iterations(self, n: usize) -> Self
pub fn max_iterations(self, n: usize) -> Self
Set the per-send iteration budget.
Sourcepub fn effort(self, level: impl Into<String>) -> Self
pub fn effort(self, level: impl Into<String>) -> Self
Set the reasoning/effort level (reasoning_effort).
Sourcepub fn response_format(self, format: Value) -> Self
pub fn response_format(self, format: Value) -> Self
Constrain output to a JSON schema (response_format).
Sourcepub fn extra_body_field(self, key: impl Into<String>, value: Value) -> Self
pub fn extra_body_field(self, key: impl Into<String>, value: Value) -> Self
Merge an extra request-body field (provider-native passthrough).
Sourcepub fn max_tool_output_bytes(self, n: usize) -> Self
pub fn max_tool_output_bytes(self, n: usize) -> Self
Cap cumulative output tokens across one send loop.
Cap a single tool result at n bytes (see
Config::max_tool_output_bytes). Pass 0 only via the field to disable.
Sourcepub fn max_total_output_tokens(self, n: u64) -> Self
pub fn max_total_output_tokens(self, n: u64) -> Self
Cap on cumulative output tokens across one send loop.
Sourcepub fn add_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn add_dir(self, dir: impl Into<PathBuf>) -> Self
Add an extra root directory (--add-dir / multi-root / worktree).
Sourcepub fn project_context(self, enabled: bool) -> Self
pub fn project_context(self, enabled: bool) -> Self
Enable auto-loading of CLAUDE.md / AGENTS.md into the system prompt.
Sourcepub fn prompt(
self,
name: impl Into<String>,
template: impl Into<String>,
) -> Self
pub fn prompt( self, name: impl Into<String>, template: impl Into<String>, ) -> Self
Register a named prompt template (skill / slash command).
Sourcepub fn compact_after_messages(self, n: usize) -> Self
pub fn compact_after_messages(self, n: usize) -> Self
Compact the conversation once it exceeds n messages.
Sourcepub fn sandbox(self, policy: SandboxPolicy) -> Self
pub fn sandbox(self, policy: SandboxPolicy) -> Self
Set the filesystem sandbox policy for write-capable tools.
Sourcepub fn approval(self, policy: ApprovalPolicy) -> Self
pub fn approval(self, policy: ApprovalPolicy) -> Self
Set the tool-approval policy.
Sourcepub fn auto_approve_tool(self, name: impl Into<String>) -> Self
pub fn auto_approve_tool(self, name: impl Into<String>) -> Self
Add a tool to the auto-approve allowlist (no approval under OnRequest).
Sourcepub fn approval_handler(
self,
handler: Box<dyn Fn(&ToolCall) -> bool + Send + Sync>,
) -> Self
pub fn approval_handler( self, handler: Box<dyn Fn(&ToolCall) -> bool + Send + Sync>, ) -> Self
Set the handler consulted when a tool call needs approval.
Sourcepub fn pre_tool_hook(
self,
hook: Box<dyn Fn(&str, &Value) -> Option<String> + Send + Sync>,
) -> Self
pub fn pre_tool_hook( self, hook: Box<dyn Fn(&str, &Value) -> Option<String> + Send + Sync>, ) -> Self
Set the pre-tool hook (may block a call by returning Some(reason)).
Sourcepub fn post_tool_hook(
self,
hook: Box<dyn Fn(&str, &str, bool) + Send + Sync>,
) -> Self
pub fn post_tool_hook( self, hook: Box<dyn Fn(&str, &str, bool) + Send + Sync>, ) -> Self
Set the post-tool hook (observational).
Sourcepub fn disable_tool(self, name: impl Into<String>) -> Self
pub fn disable_tool(self, name: impl Into<String>) -> Self
Disable a tool by name.
Sourcepub fn enable_tool(self, name: impl Into<String>) -> Self
pub fn enable_tool(self, name: impl Into<String>) -> Self
Enable a tool by name (overriding a prior disable).
Sourcepub fn tool_description(
self,
name: impl Into<String>,
description: impl Into<String>,
) -> Self
pub fn tool_description( self, name: impl Into<String>, description: impl Into<String>, ) -> Self
Override the description the model sees for a tool.
Sourcepub fn header(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn header(self, key: impl Into<String>, value: impl Into<String>) -> Self
Add an extra HTTP header sent on every request.
Sourcepub fn event_sink(self, sink: EventSink) -> Self
pub fn event_sink(self, sink: EventSink) -> Self
Attach a streaming event sink.