Universal.Operative.Sdk.Discrete.Anthropic
2.0.3
See the version list below for details.
dotnet add package Universal.Operative.Sdk.Discrete.Anthropic --version 2.0.3
NuGet\Install-Package Universal.Operative.Sdk.Discrete.Anthropic -Version 2.0.3
<PackageReference Include="Universal.Operative.Sdk.Discrete.Anthropic" Version="2.0.3" />
<PackageVersion Include="Universal.Operative.Sdk.Discrete.Anthropic" Version="2.0.3" />
<PackageReference Include="Universal.Operative.Sdk.Discrete.Anthropic" />
paket add Universal.Operative.Sdk.Discrete.Anthropic --version 2.0.3
#r "nuget: Universal.Operative.Sdk.Discrete.Anthropic, 2.0.3"
#:package Universal.Operative.Sdk.Discrete.Anthropic@2.0.3
#addin nuget:?package=Universal.Operative.Sdk.Discrete.Anthropic&version=2.0.3
#tool nuget:?package=Universal.Operative.Sdk.Discrete.Anthropic&version=2.0.3
Universal.Operative.Sdk.Discrete.Anthropic
About
Universal.Operative.Sdk.Discrete.Anthropic plugs Anthropic's Messages API into Universal.Operative.Sdk via an IModel adapter (Model) backed by the Universal.Anthropic.Client transport, plus a small set of Anthropic-specific extensions (prompt caching, extended thinking, per-block cache_control) that don't belong in the provider-neutral core.
How to Use
Installation
dotnet add package Universal.Operative.Sdk.Discrete.Anthropic
Configuration
using Universal.Operative.Sdk;
using Universal.Operative.Sdk.Discrete.Anthropic;
IModel model = new Model("sk-ant-...", new Model.Options
{
ModelId = "claude-sonnet-4-6",
MaxTokens = 4096, // required by Anthropic; defaults to 1024
Temperature = 1.0f,
UsePromptCaching = true, // default: stamps ephemeral cache_control on system/tools automatically
});
The constructor also accepts an existing Universal.Anthropic.Client.V1.AnthropicClient in place of a raw API key, so you can reuse a client (custom HttpClient, headers) across models.
Usage
Drop the model into EngineBuilder like any other IModel:
IEngine engine = EngineBuilder.FromDefaults(model)
.AddBaselineToolSet()
.Build();
await foreach (EngineEvent e in engine.ExecuteAsync(conversation))
{
// handle events as usual — see Universal.Operative.Sdk's Package.md
}
Extended thinking
Set Model.Options.Thinking to enable Claude's extended-thinking mode; thinking blocks round-trip through the same provider-neutral Block model as everything else.
Prompt caching
With UsePromptCaching (default true), the adapter automatically stamps ephemeral cache_control breakpoints on the system prompt and tool definitions so they're reused from Anthropic's prompt cache across turns — no extra code needed for the common case.
To control caching on individual content blocks yourself, use the Anthropic extension property added onto Block:
using Universal.Operative.Sdk.Discrete.Anthropic;
block.Anthropic.CacheControl = new CacheControl { Ttl = "1h" };
Refusals
When Anthropic ends a streamed turn with stop_reason: refusal, the provider category and explanation are retained on the settled message:
if (message.StopReason == StopReasons.Refusal)
{
string? category = message.Anthropic.RefusalCategory;
string? explanation = message.Anthropic.RefusalExplanation;
}
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 | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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. |
-
net10.0
- Universal.Anthropic.Client (>= 3.1.2)
- Universal.Common.Formats.Gif (>= 2.1.0)
- Universal.Common.Formats.Jpeg (>= 2.1.3)
- Universal.Common.Formats.Png (>= 2.2.0)
- Universal.Common.Formats.WebP (>= 2.0.0)
- Universal.Common.Image (>= 2.0.0)
- Universal.Operative.Sdk (>= 6.0.2)
- Universal.Operative.Sdk.Discrete (>= 2.1.0)
-
net8.0
- Universal.Anthropic.Client (>= 3.1.2)
- Universal.Common.Formats.Gif (>= 2.1.0)
- Universal.Common.Formats.Jpeg (>= 2.1.3)
- Universal.Common.Formats.Png (>= 2.2.0)
- Universal.Common.Formats.WebP (>= 2.0.0)
- Universal.Common.Image (>= 2.0.0)
- Universal.Operative.Sdk (>= 6.0.2)
- Universal.Operative.Sdk.Discrete (>= 2.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Preserves empty signed thinking blocks for Claude tool continuations and filters incompatible foreign-model reasoning during provider switches.