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

# Embedding Agent • Rust AI Agent SDK

> EmbeddingAgent: Agent for generating text embeddings. Provides embedding capabilities for text using AI embedding models, with support for batch processing and...

# EmbeddingAgent

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

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

Agent for generating text embeddings. Provides embedding capabilities for text using AI embedding models, with support for batch processing and similarity calculations. # Supported Providers - OpenAI: `text-embedding-3-small`, `text-embedding-3-large`, `text-embedding-ada-002` - Azure: `azure/text-embedding-3-small` - Cohere: `cohere/embed-english-v3.0` - Voyage: `voyage/voyage-3` - Mistral: `mistral/mistral-embed`

```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: EmbeddingAgent"]
    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`    | `String`          | Agent name              |
| `model`   | `String`          | Model name              |
| `config`  | `EmbeddingConfig` | Embedding configuration |
| `verbose` | `bool`            | Verbose output          |

## Methods

### `new`

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

Create a new builder

### `simple`

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

Create a simple embedding agent with default settings

### `embed`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
async fn embed(&self, text: &str) -> Result<Vec<f32>>
```

Generate embedding for a single text. # Arguments \* `text` - Text to embed # Returns Vector of floats representing the embedding

**Parameters:**

| Name   | Type   |
| ------ | ------ |
| `text` | `&str` |

### `embed_batch`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
async fn embed_batch(&self, texts: &[&str]) -> Result<EmbeddingResult>
```

Generate embeddings for multiple texts. # Arguments \* `texts` - Slice of texts to embed # Returns EmbeddingResult containing all embeddings

**Parameters:**

| Name    | Type      |
| ------- | --------- |
| `texts` | `&[&str]` |

### `similarity`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
async fn similarity(&self, text1: &str, text2: &str) -> Result<f32>
```

Calculate cosine similarity between two texts. # Arguments \* `text1` - First text \* `text2` - Second text # Returns Cosine similarity score (0.0 to 1.0)

**Parameters:**

| Name    | Type   |
| ------- | ------ |
| `text1` | `&str` |
| `text2` | `&str` |

### `find_most_similar`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
async fn find_most_similar(
        &self,
        query: &str,
        candidates: &[&str],
        top_k: usize,
    ) -> Result<Vec<SimilarityResult>>
```

Find the most similar texts to a query. # Arguments \* `query` - Query text \* `candidates` - List of candidate texts to compare \* `top_k` - Number of top results to return # Returns List of SimilarityResult sorted by score (descending)

**Parameters:**

| Name         | Type      |
| ------------ | --------- |
| `query`      | `&str`    |
| `candidates` | `&[&str]` |
| `top_k`      | `usize`   |

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-rust/praisonai/src/embedding/mod.rs#L229">
  `praisonai/src/embedding/mod.rs` at line 229
</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>
