Path: redb-route/redb.Route.Llm/Providers/ILlmProvider.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/ILlmProvider.cs
----
namespace redb.Route.Llm.Providers;
///
/// Pure transport abstraction over an LLM API. Implementations are responsible
/// for protocol-level work only: serialise , call the
/// provider's HTTP/SDK, deserialise .
///
/// Tool dispatch, conversation persistence, budget enforcement and shadow-mode
/// belong to , not here.
///
///
public interface ILlmProvider
{
/// Provider identifier ("anthropic", "openai", "stub", ...).
string ProviderId { get; }
/// Model identifier this provider was configured with.
string ModelId { get; }
/// Performs a single non-streaming completion call.
Task CompleteAsync(LlmRequest request, CancellationToken ct = default);
///
/// Performs a streaming completion. Yields the pieces as they arrive (visible text as
/// , thinking as ) and ends with a chunk that
/// carries the stop reason, the usage and : the whole answer,
/// exactly what returns for it. A stream that ends before the model said
/// why it stopped is a cut answer and fails. Default implementation buffers
/// as a single chunk — override for true token-streaming.
///
async IAsyncEnumerable StreamAsync(
LlmRequest request,
[System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken ct = default)
{
var response = await CompleteAsync(request, ct).ConfigureAwait(false);
yield return new LlmStreamChunk(response.Content, response.StopReason, response.Usage) { Response = response };
}
}