Universal.Operative.Sdk.Discrete.OpenAI
4.0.1
dotnet add package Universal.Operative.Sdk.Discrete.OpenAI --version 4.0.1
NuGet\Install-Package Universal.Operative.Sdk.Discrete.OpenAI -Version 4.0.1
<PackageReference Include="Universal.Operative.Sdk.Discrete.OpenAI" Version="4.0.1" />
<PackageVersion Include="Universal.Operative.Sdk.Discrete.OpenAI" Version="4.0.1" />
<PackageReference Include="Universal.Operative.Sdk.Discrete.OpenAI" />
paket add Universal.Operative.Sdk.Discrete.OpenAI --version 4.0.1
#r "nuget: Universal.Operative.Sdk.Discrete.OpenAI, 4.0.1"
#:package Universal.Operative.Sdk.Discrete.OpenAI@4.0.1
#addin nuget:?package=Universal.Operative.Sdk.Discrete.OpenAI&version=4.0.1
#tool nuget:?package=Universal.Operative.Sdk.Discrete.OpenAI&version=4.0.1
Universal.Operative.Sdk.Discrete.OpenAI
About
Universal.Operative.Sdk.Discrete.OpenAI plugs OpenAI into Universal.Operative.Sdk by providing two IModel adapters backed by the Universal.OpenAI.Client transport:
ChatCompletionsModeltargets the Chat Completions endpoint and compatible servers.ResponsesModeltargets the Responses API with encrypted reasoning replay and function/custom tools, plus native shell and apply_patch contracts. Requests are stateless (store=false): full history is sent on every turn. Hosted-tool items already present in history can be replayed; the adapter does not configure hosted tools or structured response schemas.
Both adapters stream provider events and fold them into the SDK's provider-neutral StreamEvent sequence, so the rest of the harness (tool dispatch, transformers, event stream) is identical regardless of which one you pick.
Persisted conversations can move between providers. At request serialization, both adapters convert provider-hosted tool activity into bounded text context, omit unsupported provider-specific blocks, and remove unmatched historical tool calls/results that OpenAI cannot replay safely.
How to Use
Installation
dotnet add package Universal.Operative.Sdk.Discrete.OpenAI
Configuration
using Universal.Operative.Sdk;
using Universal.Operative.Sdk.Discrete;
using Universal.OpenAI.Client.V1.Responses;
using Universal.Operative.Sdk.Discrete.OpenAI;
// Chat Completions — also works against Azure OpenAI / vLLM / OpenRouter / etc.
// via the Universal.OpenAI.Client's base-URL configuration.
using ChatCompletionsModel model = new ChatCompletionsModel("sk-...", new ChatCompletionsModel.Options { ModelId = "gpt-4.1", MaxCompletionTokens = 4096, Temperature = 0.7f, });
// Responses API — supports encrypted reasoning replay.
using ResponsesModel reasoningModel = new ResponsesModel("sk-...", new ResponsesModel.Options { ModelId = "gpt-5.4", ReasoningEffort = ReasoningEfforts.High, Include = new[] { "reasoning.encrypted_content" }, // round-trip reasoning across stateless turns
});
Adapters dispose clients they create. Injected clients remain owned by the caller.
Both constructors also accept an existing Universal.OpenAI.Client.V1.V1Client in place of a raw API key, so you can reuse a client (custom HttpClient, base address, headers) across models.
Usage
Either model drops straight into EngineBuilder:
using Universal.Operative.Sdk.Tools.Coding;
IEngine engine = EngineBuilder.FromDefaults(model).AddCodingToolSet(new CodingToolSet.Options { WorkingDirectory = workspace }).Build();
ConversationManager manager = await ConversationManager.CreateAsync(conversation, cancellationToken: CancellationToken.None);
await foreach (EngineEvent e in engine.ExecuteAsync(new Universal.Operative.Sdk.Discrete.ExecutionContext(new TurnContext()), manager, CancellationToken.None))
{
// handle events as usual — see Universal.Operative.Sdk's Package.md
}
AddCodingToolSet works with every model adapter as normal function tools. ResponsesModel additionally maps shell and apply_patch to native wire contracts; update_plan remains a function tool.
ParallelToolCalls (both models) controls whether OpenAI may emit more than one tool call per turn. ReasoningEffort (both) accepts the constants on Universal.OpenAI.Client.V1.Responses.ReasoningEfforts ("minimal", "low", "medium", "high"). ResponsesModel additionally exposes Truncation and ServiceTier for endpoint-specific knobs.
Prompt caching
Both adapters leave OpenAI's automatic prompt caching enabled with their default options. Keep the system instructions, tool definitions, and earlier conversation turns stable to reuse a prefix. No model response is cached by the SDK.
Both models expose PromptCacheKey, PromptCacheKeySelector, PromptCacheRetention, PromptCacheOptions, PromptCacheSystemBreakpoint, and PromptCacheBreakpointSelector. A key selector can supply a stable, application-scoped key for each conversation; its non-null result overrides PromptCacheKey. Leave these options unset to use provider defaults. PromptCacheSystemBreakpoint places an explicit breakpoint at the end of the system content (in Responses, this moves the instructions into an initial developer input message). PromptCacheBreakpointSelector marks selected user content blocks, for example the end of a large, stable reference document before a changing question. Use breakpoints only with models that support them and a prefix long enough to cache. For GPT-5.6 and later, PromptCacheOptions can set Mode = "explicit" and Ttl = "30m"; explicit-only mode requires at least one eligible breakpoint in the request or caching is disabled. Earlier models use PromptCacheRetention where supported.
Provider usage details appear in Usage.Extensions["openai"] as cachedTokens and cacheWriteTokens when returned by the provider. A zero value is reported as zero, distinct from an absent field. Cache hits can reduce input processing cost and time to the first generated token; they do not cache a whole answer.
License
Free for noncommercial use under the Universal.Operative Noncommercial License. Source is closed; commercial use requires a separate license from Andrew Ong.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. net11.0 is compatible. |
-
net10.0
- Universal.OpenAI.Client (>= 4.6.1)
- Universal.Operative.Sdk.Discrete (>= 4.0.0)
-
net11.0
- Universal.OpenAI.Client (>= 4.6.1)
- Universal.Operative.Sdk.Discrete (>= 4.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.1 | 78 | 11/18/2026 |
| 4.0.0 | 97 | 11/18/2026 |
| 3.5.1 | 126 | 11/16/2026 |
| 3.5.0 | 148 | 11/11/2026 |
| 3.4.0 | 98 | 11/11/2026 |
| 3.3.0 | 119 | 11/10/2026 |
| 3.2.0 | 224 | 10/2/2026 |
| 3.1.1 | 128 | 10/1/2026 |
| 3.1.0 | 120 | 10/1/2026 |
| 3.0.1 | 124 | 9/28/2026 |
| 3.0.0 | 157 | 9/7/2026 |
| 2.0.2 | 134 | 9/2/2026 |
| 2.0.1 | 129 | 9/1/2026 |
| 2.0.0 | 127 | 9/1/2026 |
| 1.1.0 | 146 | 8/26/2026 |
| 1.0.2 | 150 | 8/24/2026 |
| 1.0.1 | 138 | 8/22/2026 |
| 1.0.0 | 149 | 8/12/2026 |
Dependency maintenance: Update Universal.OpenAI.Client from 4.6.0 to 4.6.1.