Universal.Operative.Sdk.Discrete.Microsoft.Foundry 1.3.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package Universal.Operative.Sdk.Discrete.Microsoft.Foundry --version 1.3.3
                    
NuGet\Install-Package Universal.Operative.Sdk.Discrete.Microsoft.Foundry -Version 1.3.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Universal.Operative.Sdk.Discrete.Microsoft.Foundry" Version="1.3.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Universal.Operative.Sdk.Discrete.Microsoft.Foundry" Version="1.3.3" />
                    
Directory.Packages.props
<PackageReference Include="Universal.Operative.Sdk.Discrete.Microsoft.Foundry" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Universal.Operative.Sdk.Discrete.Microsoft.Foundry --version 1.3.3
                    
#r "nuget: Universal.Operative.Sdk.Discrete.Microsoft.Foundry, 1.3.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Universal.Operative.Sdk.Discrete.Microsoft.Foundry@1.3.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Universal.Operative.Sdk.Discrete.Microsoft.Foundry&version=1.3.3
                    
Install as a Cake Addin
#tool nuget:?package=Universal.Operative.Sdk.Discrete.Microsoft.Foundry&version=1.3.3
                    
Install as a Cake Tool

Universal.Operative.Sdk.Discrete.Microsoft.Foundry

Documents and failures

OpenAIResponses maps DocumentBlock to native input_file content for base64 data, public URLs, and OpenAI file IDs, including document-only messages. Inline data uses the source media type and Title as the filename (default document.pdf). TextSource documents become input_text. Unsupported source kinds and file IDs explicitly issued by other providers throw NotSupportedException. File availability, supported formats, size limits, and model document capabilities remain provider constraints.

HTTP failures propagate Universal.Microsoft.Foundry.Client.FoundryException unchanged: use StatusCode (for example, HTTP 429), ResponseBody, and RequestId. Provider-reported failures in HTTP-success bodies or streaming events throw FoundryResponseException, exposing ErrorCode, ErrorType, and an independent Payload copy. These fields are provider-supplied and may be absent. Unexpected stream termination remains a protocol failure (InvalidOperationException). Applications choose fallback and retry policy; they need not parse exception messages to identify provider-reported rate-limit codes or HTTP status codes.

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.

OpenAI function strictness

For OpenAIChat and OpenAIResponses, the adapter forwards a boolean ToolDefinition.Extensions["openai"]["strict"] to each function definition in both buffered and streaming requests. Explicit false remains "strict": false; explicit true remains "strict": true. An absent or null setting omits the wire field and leaves provider defaults in effect.

Chat Completions places it at tools[].function.strict; Responses places it at tools[].strict. The adapter forwards the supplied parameter schema without changing required, adding nullable alternatives, or closing objects. In particular, disabling strictness preserves optional properties. When enabling strictness, the caller supplies a compatible schema. The OpenAI hint does not change Anthropic or MAI tool definitions.

Legacy Office compatibility editors already set this hint to false; focused strict tools set it to true. Foundry 1.3.3 carries that existing setting through to the provider without requiring another Office, core SDK, or discrete runtime update.

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 anthropic extension as the direct Anthropic adapter holds cacheReadInputTokens and cacheCreationInputTokens. Claude's Usage.InputTokens is the uncached portion; use usage.GetTotalInputTokens() to include cache reads and writes. Use FoundryUsageExtensions.ProjectCompactionTokens as 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.0.0 81 11/18/2026
1.3.3 72 11/17/2026
1.3.2 97 11/16/2026
1.3.1 97 11/16/2026
1.3.0 109 11/11/2026
1.2.0 89 11/11/2026
1.1.1 1,216 10/2/2026
1.1.0 216 10/1/2026
1.0.0 1,160 9/28/2026

Forwards explicit OpenAI tool strictness hints for Chat Completions and Responses, in buffered and streaming requests. Preserves explicit false, explicit true, absent settings, and supplied parameter schemas including optional fields. Core and discrete runtime dependency versions remain unchanged.