> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent Builder • Rust AI Agent SDK

> AgentBuilder: Builder for creating agents

# AgentBuilder

> Defined in the [**builder**](../modules/builder) module.

<Badge color="orange">Rust AI Agent SDK</Badge>

Builder for creating agents

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#8B0000', 'primaryTextColor': '#fff', 'primaryBorderColor': '#710101', 'lineColor': '#189AB4', 'secondaryColor': '#189AB4', 'tertiaryColor': '#fff' }}}%%

graph LR
    input["Input Data"] --> agent["Agent: AgentBuilder"]
    agent --> output["Output Result"]
    style agent fill:#8B0000,color:#fff
    style input fill:#8B0000,color:#fff
    style output fill:#8B0000,color:#fff
```

## Fields

| Name            | Type                             | Description |
| --------------- | -------------------------------- | ----------- |
| `name`          | `Option&lt;String&gt;`           | -           |
| `instructions`  | `Option&lt;String&gt;`           | -           |
| `llm_config`    | `LlmConfig`                      | -           |
| `tools`         | `Vec&lt;Box&lt;dyn Tool&gt;&gt;` | -           |
| `memory_config` | `MemoryConfig`                   | -           |
| `config`        | `AgentConfig`                    | -           |

## Methods

### `new`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn new() -> Self
```

Create a new agent builder

### `name`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn name(mut self, name: impl Into<String>) -> Self
```

Set the agent name

**Parameters:**

| Name   | Type                      |
| ------ | ------------------------- |
| `name` | `impl Into&lt;String&gt;` |

### `instructions`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn instructions(mut self, instructions: impl Into<String>) -> Self
```

Set the system instructions

**Parameters:**

| Name           | Type                      |
| -------------- | ------------------------- |
| `instructions` | `impl Into&lt;String&gt;` |

### `model`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn model(mut self, model: impl Into<String>) -> Self
```

Set the LLM model

**Parameters:**

| Name    | Type                      |
| ------- | ------------------------- |
| `model` | `impl Into&lt;String&gt;` |

### `llm`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn llm(self, model: impl Into<String>) -> Self
```

Alias for model() - matches Python SDK

**Parameters:**

| Name    | Type                      |
| ------- | ------------------------- |
| `model` | `impl Into&lt;String&gt;` |

### `api_key`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn api_key(mut self, key: impl Into<String>) -> Self
```

Set the API key

**Parameters:**

| Name  | Type                      |
| ----- | ------------------------- |
| `key` | `impl Into&lt;String&gt;` |

### `base_url`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn base_url(mut self, url: impl Into<String>) -> Self
```

Set the base URL for the LLM API

**Parameters:**

| Name  | Type                      |
| ----- | ------------------------- |
| `url` | `impl Into&lt;String&gt;` |

### `temperature`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn temperature(mut self, temp: f32) -> Self
```

Set the temperature

**Parameters:**

| Name   | Type  |
| ------ | ----- |
| `temp` | `f32` |

### `max_tokens`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn max_tokens(mut self, max: u32) -> Self
```

Set max tokens

**Parameters:**

| Name  | Type  |
| ----- | ----- |
| `max` | `u32` |

### `tool`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn tool(mut self, tool: impl Tool + 'static) -> Self
```

Add a tool

**Parameters:**

| Name   | Type                  |
| ------ | --------------------- |
| `tool` | `impl Tool + 'static` |

### `tools`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn tools(mut self, tools: impl IntoIterator<Item = impl Tool + 'static>) -> Self
```

Add multiple tools

**Parameters:**

| Name    | Type                        |
| ------- | --------------------------- |
| `tools` | `impl IntoIterator&lt;Item` |

### `memory`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn memory(mut self, enabled: bool) -> Self
```

Enable memory

**Parameters:**

| Name      | Type   |
| --------- | ------ |
| `enabled` | `bool` |

### `memory_config`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn memory_config(mut self, config: MemoryConfig) -> Self
```

Set memory configuration

**Parameters:**

| Name     | Type           |
| -------- | -------------- |
| `config` | `MemoryConfig` |

### `max_iterations`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn max_iterations(mut self, max: usize) -> Self
```

Set max iterations for tool calling

**Parameters:**

| Name  | Type    |
| ----- | ------- |
| `max` | `usize` |

### `verbose`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn verbose(mut self, enabled: bool) -> Self
```

Enable verbose output

**Parameters:**

| Name      | Type   |
| --------- | ------ |
| `enabled` | `bool` |

### `stream`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn stream(mut self, enabled: bool) -> Self
```

Enable/disable streaming

**Parameters:**

| Name      | Type   |
| --------- | ------ |
| `enabled` | `bool` |

### `build`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn build(self) -> Result<Agent>
```

Build the agent

## Usage

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
let agent = Agent::new()
.name("assistant")
.instructions("You are helpful")
.model("gpt-4o-mini")
.build()?;
```

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-rust/praisonai/src/agent/builder.rs#L47">
  `praisonai/src/agent/builder.rs` at line 47
</Card>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Rust Agent" icon="robot" href="/docs/rust/agent" />

  <Card title="Rust Overview" icon="book-open" href="/docs/rust/overview" />

  <Card title="Rust Quickstart" icon="rocket" href="/docs/rust/quickstart" />

  <Card title="Rust Installation" icon="download" href="/docs/rust/installation" />

  <Card title="Rust Autonomy" icon="wand-magic-sparkles" href="/docs/rust/autonomy" />
</CardGroup>
