Class OpenAiProvider

Assembly: redb.Route.Llm.dll

Transport for any OpenAI-compatible Chat Completions endpoint
(POST {baseUrl}/chat/completions).

One implementation, many providers. By switching
+ +
the same provider talks to OpenAI, Groq, Cerebras, OpenRouter, Google Gemini
(compat mode), GitHub Models, Mistral, Together, HuggingFace router, DeepSeek,
xAI Grok, LM Studio, vLLM, llama.cpp server and Ollama.


Maps ↔ OpenAI messages/tools/tool_calls
and ↔ choices[0].message + finish_reason
+ usage. Streaming falls back to the buffered default of
.

public sealed class OpenAiProvider : ILlmProvider

Inheritance

Object→OpenAiProvider

Implements

Properties

ModelId

Model identifier this provider was configured with.

public string ModelId { get; }

ProviderId

Provider identifier ("anthropic", "openai", "stub", ...).

public string ProviderId { get; }

Methods

CompleteAsync(LlmRequest, CancellationToken)

Performs a single non-streaming completion call.

public Task<LlmResponse> CompleteAsync(LlmRequest request, CancellationToken ct = default)

Create(LlmConnectionFactory)

Convenience constructor that builds the package's default client: the factory timeout, HTTP/2 with keep-alive

public static OpenAiProvider Create(LlmConnectionFactory factory)

ResolveDefaultBaseUrl(string?)

Default base URL applied when is null.

public static Uri ResolveDefaultBaseUrl(string? providerKey)

StreamAsync(LlmRequest, CancellationToken)

True OpenAI SSE streaming. Pieces are yielded as they arrive: visible text as , the

public IAsyncEnumerable<LlmStreamChunk> StreamAsync(LlmRequest request, CancellationToken ct = default)

Constructors

OpenAiProvider(LlmConnectionFactory, HttpClient)

Creates the provider with an externally owned http.