Skip to content
Tracon

OpenAICompatibleProviderExtensions

Namespace Tracon · Assembly Tracon.OpenAI.dll

Extensions that add named providers with an OpenAI compatible chat API to the Tracon chain (OpenRouter, Groq, vLLM, Ollama, LM Studio, …).

public static class OpenAICompatibleProviderExtensions
Inheritance
object ← OpenAICompatibleProviderExtensions
Inherited Members
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

The difference from UseOpenAI: this call takes a name and registers one or two providers (see OpenAIProviderOptions.EnableResponsesSurface) under that name. It uses the same OpenAIProviderOptions shape; the base address (OpenAIProviderOptions.Endpoint) points at the compatible server.

Only the Chat Completions surface is registered; the Responses surface is off by default (most compatible servers do not implement /v1/responses).

UseOpenAICompatible(ITraconBuilder, string, Action<OpenAIProviderOptions>)

Section titled “ UseOpenAICompatible(ITraconBuilder, string, Action<OpenAIProviderOptions>)”

Adds a named OpenAI compatible provider whose options are set in code.

public static ITraconBuilder UseOpenAICompatible(this ITraconBuilder builder, string name, Action<OpenAIProviderOptions> configure)

builder ITraconBuilder

The Tracon chain.

name string

The provider name. It is limited to [a-z0-9][a-z0-9-]{0,31}. OpenAIProviderNames.ChatCompletions and OpenAIProviderNames.Responses are reserved.

configure Action<OpenAIProviderOptions>

The options callback. It must set at least OpenAIProviderOptions.Endpoint.

ITraconBuilder

The same chain, for chaining.

builder.AddTracon()
.UseOpenAICompatible("openrouter", o =>
{
o.Endpoint = new Uri("https://openrouter.ai/api/v1");
o.ApiKey = configuration["OpenRouter:ApiKey"];
})
.UseOpenAICompatible("ollama", o =>
{
o.Endpoint = new Uri("http://localhost:11434/v1");
// No ApiKey — the local server does not ask for one
});

ArgumentNullException

builder or configure is null.

ArgumentException

name is empty, reserved, or does not match the pattern.

UseOpenAICompatible(ITraconBuilder, string, IConfiguration)

Section titled “ UseOpenAICompatible(ITraconBuilder, string, IConfiguration)”

Adds a named OpenAI compatible provider whose options are read from the Tracon:Providers:OpenAICompatible:{name} section.

public static ITraconBuilder UseOpenAICompatible(this ITraconBuilder builder, string name, IConfiguration configurationSection)

builder ITraconBuilder

The Tracon chain.

name string

The provider name. See OpenAICompatibleProviderExtensions.UseOpenAICompatible.

configurationSection IConfiguration

The section the options are read from. Usually configuration.GetSection($"{OpenAICompatibleProviderOptions.SectionName}:{name}").

ITraconBuilder

The same chain, for chaining.

ArgumentNullException

Any parameter is null.