pub struct AgentBuilder { /* private fields */ }Expand description
Agent builder for configuring and creating agents.
Implementations§
Source§impl AgentBuilder
impl AgentBuilder
Sourcepub fn with_config(self, config: AgentConfig) -> Self
pub fn with_config(self, config: AgentConfig) -> Self
Set the agent configuration.
Sourcepub fn with_system_prompt(self, prompt: impl Into<String>) -> Self
pub fn with_system_prompt(self, prompt: impl Into<String>) -> Self
Set the system prompt.
Sourcepub fn with_max_concurrent_llm_calls(self, n: usize) -> Self
pub fn with_max_concurrent_llm_calls(self, n: usize) -> Self
Set max concurrent LLM calls.
Sourcepub fn with_spider_cloud(self, api_key: impl Into<String>) -> Self
pub fn with_spider_cloud(self, api_key: impl Into<String>) -> Self
Register Spider Cloud tools using an API key.
Registers /crawl, /scrape, /search, /links, /transform, and
/unblocker.
AI routes remain disabled unless enabled in with_spider_cloud_config.
Sourcepub fn with_spider_cloud_config(self, config: SpiderCloudToolConfig) -> Self
pub fn with_spider_cloud_config(self, config: SpiderCloudToolConfig) -> Self
Register Spider Cloud tools using a full config.
Use this when you need custom API URL, route toggles, or AI route gating.
Sourcepub fn with_spider_browser(self, api_key: impl Into<String>) -> Self
pub fn with_spider_browser(self, api_key: impl Into<String>) -> Self
Register Spider Browser Cloud tools.
Connects to a remote browser instance at wss://browser.spider.cloud/v1/browser
via CDP. Registers navigate, html, screenshot, evaluate, click, fill, and wait tools.
Sourcepub fn with_spider_browser_config(self, config: SpiderBrowserToolConfig) -> Self
pub fn with_spider_browser_config(self, config: SpiderBrowserToolConfig) -> Self
Register Spider Browser Cloud tools using a full config.
Use this when you need stealth mode, country targeting, or custom WSS URL.
Sourcepub fn with_timeout(self, timeout: Option<Duration>) -> Self
pub fn with_timeout(self, timeout: Option<Duration>) -> Self
Sourcepub fn with_client(self, client: Client) -> Self
pub fn with_client(self, client: Client) -> Self
Provide a pre-built reqwest::Client.
When set, the builder skips its own client construction (timeout, proxy settings, etc.) and uses this client directly. This gives full control over TLS, timeouts, connection pools, and proxies.
§Example
let client = reqwest::Client::builder()
.timeout(std::time::Duration::from_secs(120))
.proxy(reqwest::Proxy::all("http://proxy:8080")?)
.build()?;
let agent = Agent::builder()
.with_client(client)
.with_openai("sk-...", "gpt-4o")
.build()?;Sourcepub fn with_proxies(self, proxies: Vec<String>) -> Self
pub fn with_proxies(self, proxies: Vec<String>) -> Self
Configure one or more HTTP/SOCKS proxies.
Each entry is a proxy URL (e.g. http://host:port, socks5://host:port).
The first proxy is applied to the underlying HTTP client; additional
proxies are added via reqwest::Proxy::all.
§Example
let agent = Agent::builder()
.with_openai("sk-...", "gpt-4o")
.with_proxies(vec!["http://proxy.example.com:8080".into()])
.build()?;Sourcepub fn with_proxy(self, proxy: impl Into<String>) -> Self
pub fn with_proxy(self, proxy: impl Into<String>) -> Self
Configure a single HTTP/SOCKS proxy.
Sourcepub fn build(self) -> AgentResult<Agent>
pub fn build(self) -> AgentResult<Agent>
Build the agent.