Path: redb-route/redb.Route.Llm/LlmEndpoint.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/LlmEndpoint.cs
----
using redb.Route.Abstractions;
using redb.Route.Core;
using redb.Route.Llm.Engine;
namespace redb.Route.Llm;
///
/// LLM endpoint. The URI host is interpreted as the connection-factory name.
///
public sealed class LlmEndpoint : EndpointBase
{
/// Connection factory name (from URI host or connectionFactory query).
public string ConnectionFactoryName { get; }
/// Resolved connection factory from the registry (null if not registered yet).
internal LlmConnectionFactory? ResolvedFactory { get; }
///
/// Agent engine resolved from the route context. Created lazily on first producer/consumer
/// instantiation so that engine wiring can happen after the endpoint is created.
///
internal IAgentEngine? ResolvedEngine { get; }
/// Creates an LLM endpoint.
public LlmEndpoint(EndpointUri uri, LlmComponent component, LlmEndpointOptions options)
: base(uri, component, options)
{
// Path wins; fall back to query parameter
ConnectionFactoryName = !string.IsNullOrWhiteSpace(uri.Path)
? uri.Path
: (options.ConnectionFactory ?? string.Empty);
if (string.IsNullOrWhiteSpace(ConnectionFactoryName))
throw new InvalidOperationException(
"LLM endpoint requires a connection factory name. " +
"Use 'llm://' or '?connectionFactory='.");
if (component.Context is not null)
{
ResolvedFactory = component.Context.GetFromRegistry(ConnectionFactoryName);
ResolvedEngine = AgentEngine.FindRegistered(component.Context);
}
}
///
public override IProducer CreateProducer() => new LlmProducer(this, Options);
///
public override IConsumer CreateConsumer(IProcessor processor) => new LlmConsumer(this, Options, processor);
}