Universal.Operative.Sdk.Discrete.Microsoft.Foundry
1.1.1
dotnet add package Universal.Operative.Sdk.Discrete.Microsoft.Foundry --version 1.1.1
NuGet\Install-Package Universal.Operative.Sdk.Discrete.Microsoft.Foundry -Version 1.1.1
<PackageReference Include="Universal.Operative.Sdk.Discrete.Microsoft.Foundry" Version="1.1.1" />
<PackageVersion Include="Universal.Operative.Sdk.Discrete.Microsoft.Foundry" Version="1.1.1" />
<PackageReference Include="Universal.Operative.Sdk.Discrete.Microsoft.Foundry" />
paket add Universal.Operative.Sdk.Discrete.Microsoft.Foundry --version 1.1.1
#r "nuget: Universal.Operative.Sdk.Discrete.Microsoft.Foundry, 1.1.1"
#:package Universal.Operative.Sdk.Discrete.Microsoft.Foundry@1.1.1
#addin nuget:?package=Universal.Operative.Sdk.Discrete.Microsoft.Foundry&version=1.1.1
#tool nuget:?package=Universal.Operative.Sdk.Discrete.Microsoft.Foundry&version=1.1.1
Universal.Operative.Sdk.Discrete.Microsoft.Foundry
Quick start
dotnet add package Universal.Operative.Sdk.Discrete.Microsoft.Foundry
using Universal.Microsoft.Foundry.Client;
using Universal.Operative.Sdk.Discrete;
using Universal.Operative.Sdk.Discrete.Microsoft.Foundry;
string apiKey = Environment.GetEnvironmentVariable("FOUNDRY_API_KEY")
?? throw new InvalidOperationException("Set FOUNDRY_API_KEY.");
using var client = new FoundryClient("https://my-resource.services.ai.azure.com", apiKey);
IModel model = new FoundryModel(
client, FoundryModel.ApiShape.OpenAIResponses,
"my-deployment", maxOutputTokens: 1024);
Choose OpenAIChat, OpenAIResponses, AnthropicMessages, or MaiChat for the deployment's API. Set the model ID to its Foundry deployment name.
Prompt caching
Azure OpenAI's provider caching remains automatic by default. Eligible requests need a repeated prompt prefix of at least 1,024 tokens. FoundryModel does not cache responses. Cache usage is reported in Message.Usage.Extensions when the provider returns it:
foundry.cached_tokens: Azure OpenAI cached input tokens.foundry.cache_write_tokens: Azure OpenAI cache writes, when reported by the deployment.- For Claude, the same
anthropicextension as the direct Anthropic adapter holdscacheReadInputTokensandcacheCreationInputTokens. Claude'sUsage.InputTokensis the uncached portion; useusage.GetTotalInputTokens()to include cache reads and writes. UseFoundryUsageExtensions.ProjectCompactionTokensas a compaction transformer's projected-token calculator.
The following Azure OpenAI controls are optional. Leave them unset to keep the provider default. Select a cache key based on prompts that share a stable prefix; a per-session key can help multi-turn affinity but may reduce reuse across sessions. Hash sensitive identifiers before sending them. PromptCacheRetention applies to supported older models; PromptCacheOptions, PromptCacheSystemBreakpoint, and PromptCacheBreakpointSelector are for deployments supporting explicit breakpoints (GPT-5.6 and later Standard deployments). The selector can mark a stable text or image block in a message. Set PromptCacheOptions to { "mode": "explicit" } to avoid the implicit latest-message cache write on GPT-5.6 and later; then mark at least one reusable prefix of 1,024 tokens or more. Unsupported controls may cause the provider to reject a request.
var model = new FoundryModel(client, FoundryModel.ApiShape.OpenAIResponses,
new FoundryModel.Options
{
ModelId = "my-deployment",
PromptCacheKeySelector = conversation => GetStableHashedCacheKey(conversation),
// PromptCacheSystemBreakpoint = true,
// PromptCacheOptions = JsonSerializer.SerializeToElement(new { mode = "explicit" }),
});
Claude's Foundry Messages shape follows the direct Anthropic adapter: it marks the tools, system prompt and latest message with five-minute ephemeral cache breakpoints by default. Set UsePromptCaching = false to omit these markers, or AnthropicPromptCacheTtl = "1h" if the longer, more expensive cache is appropriate.
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.Microsoft.Foundry.Client (>= 1.0.2)
- Universal.Operative.Sdk.Discrete (>= 3.1.1)
-
net8.0
- Universal.Microsoft.Foundry.Client (>= 1.0.2)
- Universal.Operative.Sdk.Discrete (>= 3.1.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Support portable tool identifiers, dispatch restoration, and freeform tool-call replay.