Path: redb-route/redb.Route.Llm/Providers/IEmbeddingProvider.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Llm/Providers/IEmbeddingProvider.cs
----
namespace redb.Route.Llm.Providers;
///
/// Pure transport over an embeddings API — turns text into vectors. The sibling
/// of for the retrieval half of RAG: chunks are
/// embedded on ingest, the query is embedded on search, and
/// ranks by cosine
/// similarity. Implementations do protocol work only (serialise, HTTP,
/// deserialise); chunking, storage and ranking live elsewhere.
///
public interface IEmbeddingProvider
{
/// Provider identifier ("openai", "mistral", "together", ...).
string ProviderId { get; }
/// Embedding model id this provider was configured with.
string ModelId { get; }
///
/// Embeds each input text and returns one vector per input, in the same order.
/// An empty returns an empty list.
///
Task> EmbedAsync(IReadOnlyList inputs, CancellationToken ct = default);
/// Convenience single-text embed. Returns an empty array when the provider returns nothing.
async Task EmbedOneAsync(string input, CancellationToken ct = default)
{
var vectors = await EmbedAsync(new[] { input }, ct).ConfigureAwait(false);
return vectors.Count > 0 ? vectors[0] : Array.Empty();
}
}