Skip to main content

ConfigBuilder

Struct ConfigBuilder 

Source
pub struct ConfigBuilder { /* private fields */ }
Expand description

Fluent builder for Config.

Implementations§

Source§

impl ConfigBuilder

Source

pub fn apply_profile(self, p: &ConfigProfile) -> Self

Apply the set fields of a ConfigProfile over the current builder.

Source§

impl ConfigBuilder

Source

pub fn model(self, model: impl Into<String>) -> Self

Set the model identifier.

Source

pub fn base_url(self, url: impl Into<String>) -> Self

Set the OpenAI-compatible base URL (defaults to OpenRouter).

Source

pub fn api_key(self, key: impl Into<String>) -> Self

Provide the API key explicitly.

Source

pub fn api_key_env(self, var: impl Into<String>) -> Self

Change which environment variable the key is read from.

Source

pub fn system_prompt(self, prompt: impl Into<String>) -> Self

Replace the system prompt.

Source

pub fn temperature(self, t: f32) -> Self

Set the sampling temperature.

Source

pub fn max_tokens(self, n: u32) -> Self

Set the max output tokens.

Source

pub fn max_iterations(self, n: usize) -> Self

Set the per-send iteration budget.

Source

pub fn effort(self, level: impl Into<String>) -> Self

Set the reasoning/effort level (reasoning_effort).

Source

pub fn response_format(self, format: Value) -> Self

Constrain output to a JSON schema (response_format).

Source

pub fn extra_body_field(self, key: impl Into<String>, value: Value) -> Self

Merge an extra request-body field (provider-native passthrough).

Source

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.

Source

pub fn max_total_output_tokens(self, n: u64) -> Self

Cap on cumulative output tokens across one send loop.

Source

pub fn cwd(self, dir: impl Into<PathBuf>) -> Self

Set the working directory tools operate in.

Source

pub fn add_dir(self, dir: impl Into<PathBuf>) -> Self

Add an extra root directory (--add-dir / multi-root / worktree).

Source

pub fn project_context(self, enabled: bool) -> Self

Enable auto-loading of CLAUDE.md / AGENTS.md into the system prompt.

Source

pub fn prompt( self, name: impl Into<String>, template: impl Into<String>, ) -> Self

Register a named prompt template (skill / slash command).

Source

pub fn compact_after_messages(self, n: usize) -> Self

Compact the conversation once it exceeds n messages.

Source

pub fn sandbox(self, policy: SandboxPolicy) -> Self

Set the filesystem sandbox policy for write-capable tools.

Source

pub fn approval(self, policy: ApprovalPolicy) -> Self

Set the tool-approval policy.

Source

pub fn auto_approve_tool(self, name: impl Into<String>) -> Self

Add a tool to the auto-approve allowlist (no approval under OnRequest).

Source

pub fn approval_handler( self, handler: Box<dyn Fn(&ToolCall) -> bool + Send + Sync>, ) -> Self

Set the handler consulted when a tool call needs approval.

Source

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)).

Source

pub fn post_tool_hook( self, hook: Box<dyn Fn(&str, &str, bool) + Send + Sync>, ) -> Self

Set the post-tool hook (observational).

Source

pub fn disable_tool(self, name: impl Into<String>) -> Self

Disable a tool by name.

Source

pub fn enable_tool(self, name: impl Into<String>) -> Self

Enable a tool by name (overriding a prior disable).

Source

pub fn tool_description( self, name: impl Into<String>, description: impl Into<String>, ) -> Self

Override the description the model sees for a tool.

Source

pub fn header(self, key: impl Into<String>, value: impl Into<String>) -> Self

Add an extra HTTP header sent on every request.

Source

pub fn event_sink(self, sink: EventSink) -> Self

Attach a streaming event sink.

Source

pub fn build(self) -> Config

Finalize the configuration.

Trait Implementations§

Source§

impl Default for ConfigBuilder

Source§

fn default() -> ConfigBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more