# AspireOllamaEmbeddingGeneratorExtensions Methods

- Package: [CommunityToolkit.Aspire.OllamaSharp](/reference/api/csharp/communitytoolkit.aspire.ollamasharp.md)
- Type: [AspireOllamaEmbeddingGeneratorExtensions](/reference/api/csharp/communitytoolkit.aspire.ollamasharp/aspireollamaembeddinggeneratorextensions.md)
- Kind: `Methods`
- Members: `3`

Extension methos for configuring the `AI.IEmbeddingGenerator`2` from an `OllamaApiClient`

## AddEmbeddingGenerator(AspireOllamaApiClientBuilder)

- Name: `AddEmbeddingGenerator(AspireOllamaApiClientBuilder)`
- Modifiers: `extension`
- Returns: `EmbeddingGeneratorBuilder<string, Embedding<float>>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.OllamaSharp/AspireOllamaEmbeddingGeneratorExtensions.cs#L21-L22)

Registers a singleton `AI.IEmbeddingGenerator`2` in the services provided by the `builder`.

```csharp
public static class AspireOllamaEmbeddingGeneratorExtensions
{
    public static EmbeddingGeneratorBuilder<string, Embedding<float>> AddEmbeddingGenerator(
        this AspireOllamaApiClientBuilder builder)
    {
        // ...
    }
}
```

## Parameters

- `builder` ([AspireOllamaApiClientBuilder](/reference/api/csharp/communitytoolkit.aspire.ollamasharp/aspireollamaapiclientbuilder.md))
  An [AspireOllamaApiClientBuilder](/reference/api/csharp/communitytoolkit.aspire.ollamasharp/aspireollamaapiclientbuilder.md).

## Returns

`EmbeddingGeneratorBuilder<string, Embedding<float>>` -- A `AI.EmbeddingGeneratorBuilder`2` that can be used to build a pipeline around the inner `AI.IEmbeddingGenerator`2`.

## AddKeyedEmbeddingGenerator(AspireOllamaApiClientBuilder)

- Name: `AddKeyedEmbeddingGenerator(AspireOllamaApiClientBuilder)`
- Modifiers: `extension`
- Returns: `EmbeddingGeneratorBuilder<string, Embedding<float>>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.OllamaSharp/AspireOllamaEmbeddingGeneratorExtensions.cs#L33-L34)

Registers a keyed singleton `AI.IEmbeddingGenerator`2` in the services provided by the `builder`.

```csharp
public static class AspireOllamaEmbeddingGeneratorExtensions
{
    public static EmbeddingGeneratorBuilder<string, Embedding<float>> AddKeyedEmbeddingGenerator(
        this AspireOllamaApiClientBuilder builder)
    {
        // ...
    }
}
```

## Parameters

- `builder` ([AspireOllamaApiClientBuilder](/reference/api/csharp/communitytoolkit.aspire.ollamasharp/aspireollamaapiclientbuilder.md))
  An [AspireOllamaApiClientBuilder](/reference/api/csharp/communitytoolkit.aspire.ollamasharp/aspireollamaapiclientbuilder.md).

## Returns

`EmbeddingGeneratorBuilder<string, Embedding<float>>` -- A `AI.EmbeddingGeneratorBuilder`2` that can be used to build a pipeline around the inner `AI.IEmbeddingGenerator`2`.

## AddKeyedEmbeddingGenerator(AspireOllamaApiClientBuilder, object)

- Name: `AddKeyedEmbeddingGenerator(AspireOllamaApiClientBuilder, object)`
- Modifiers: `extension`
- Returns: `EmbeddingGeneratorBuilder<string, Embedding<float>>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.OllamaSharp/AspireOllamaEmbeddingGeneratorExtensions.cs#L47-L52)

Registers a keyed singleton `AI.IEmbeddingGenerator`2` in the services provided by the `builder` using the specified service key.

```csharp
public static class AspireOllamaEmbeddingGeneratorExtensions
{
    public static EmbeddingGeneratorBuilder<string, Embedding<float>> AddKeyedEmbeddingGenerator(
        this AspireOllamaApiClientBuilder builder,
        object serviceKey)
    {
        // ...
    }
}
```

## Parameters

- `builder` ([AspireOllamaApiClientBuilder](/reference/api/csharp/communitytoolkit.aspire.ollamasharp/aspireollamaapiclientbuilder.md))
  An [AspireOllamaApiClientBuilder](/reference/api/csharp/communitytoolkit.aspire.ollamasharp/aspireollamaapiclientbuilder.md).
- `serviceKey` (`object`)
  The service key to use for registering the `AI.IEmbeddingGenerator`2`.

## Returns

`EmbeddingGeneratorBuilder<string, Embedding<float>>` -- A `AI.EmbeddingGeneratorBuilder`2` that can be used to build a pipeline around the inner `AI.IEmbeddingGenerator`2`.
