IEmbeddingGenerator Feature Matrix
The IEmbeddingGenerator<string, Embedding<float>> interface provides a unified API for text embeddings across all supported providers.
Feature comparison
| Feature |
Ollama |
OpenAI |
Gemini |
Cohere |
Together |
HuggingFace |
Jina |
VoyageAI |
| Single input |
Y |
Y |
Y |
Y |
Y |
Y |
Y |
Y |
| Batch input |
Y |
Y |
Y |
Y |
Y |
Y |
Y |
Y |
| Custom dimensions |
Y |
Y |
- |
- |
- |
Y |
Y |
Y |
| Token usage |
Y |
Y |
- |
- |
- |
Y |
Y |
Y |
Universal code example
1
2
3
4
5
6
7
8
9
10
11
12
13
14 | using Microsoft.Extensions.AI;
IEmbeddingGenerator<string, Embedding<float>> generator = /* any provider */;
// Single embedding
var embedding = await generator.GenerateAsync("Hello, world!");
float[] vector = embedding[0].Vector.ToArray();
// Batch embeddings
var embeddings = await generator.GenerateAsync([
"First document",
"Second document",
"Third document"
]);
|
Provider-specific initialization
Per-SDK documentation