Rystem.PlayFramework.Adapters.FoundryLocal 10.0.11-beta.14

This is a prerelease version of Rystem.PlayFramework.Adapters.FoundryLocal.
dotnet add package Rystem.PlayFramework.Adapters.FoundryLocal --version 10.0.11-beta.14
                    
NuGet\Install-Package Rystem.PlayFramework.Adapters.FoundryLocal -Version 10.0.11-beta.14
                    
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="Rystem.PlayFramework.Adapters.FoundryLocal" Version="10.0.11-beta.14" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Rystem.PlayFramework.Adapters.FoundryLocal" Version="10.0.11-beta.14" />
                    
Directory.Packages.props
<PackageReference Include="Rystem.PlayFramework.Adapters.FoundryLocal" />
                    
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 Rystem.PlayFramework.Adapters.FoundryLocal --version 10.0.11-beta.14
                    
#r "nuget: Rystem.PlayFramework.Adapters.FoundryLocal, 10.0.11-beta.14"
                    
#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 Rystem.PlayFramework.Adapters.FoundryLocal@10.0.11-beta.14
                    
#: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=Rystem.PlayFramework.Adapters.FoundryLocal&version=10.0.11-beta.14&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Rystem.PlayFramework.Adapters.FoundryLocal&version=10.0.11-beta.14&prerelease
                    
Install as a Cake Tool

Rystem.PlayFramework.Adapters.FoundryLocal

Rystem.PlayFramework.Adapters.FoundryLocal registers local-model adapters for Rystem.PlayFramework through Microsoft Foundry Local.

It is aimed at development, demos, and local experimentation where you want an OpenAI-compatible endpoint without a cloud provider.

Installation

dotnet add package Rystem.PlayFramework.Adapters.FoundryLocal

This package includes native/runtime-specific dependencies. Your consuming app should declare an appropriate runtime identifier.

<PropertyGroup>
  <RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>

The project itself ships multiple supported runtime identifiers, but your app still needs to target one that matches its deployment environment.

Prerequisites

Foundry Local itself must be installed.

Examples:

winget install Microsoft.FoundryLocal
brew tap microsoft/foundrylocal && brew install foundrylocal

The SDK also requires the ORT NuGet feed, so keep the feed configuration described by the package in your consuming solution when needed.

Registering a local chat adapter

using Rystem.PlayFramework.Adapters.FoundryLocal;

builder.Services.AddAdapterForFoundryLocal("foundry", settings =>
{
    settings.Model = "phi-4-mini";
    settings.WebServiceUrl = "http://127.0.0.1:5272";
    settings.AppName = "Rystem.PlayFramework";
});

builder.Services.AddPlayFramework("foundry", framework =>
{
    framework.WithChatClient("foundry");
});

What happens on first use

When the adapter is first resolved, it does real work immediately:

  1. initialize FoundryLocalManager
  2. query the local model catalog
  3. download the selected model if needed
  4. load the model into memory
  5. start the local OpenAI-compatible web service
  6. create an IChatClient against {WebServiceUrl}/v1

That means startup or first-request latency can be significant, especially on a fresh machine.

Chat adapter settings

FoundryLocalSettings exposes:

Property Meaning
Model model alias, default phi-4-mini
AppName app identifier used by Foundry Local
WebServiceUrl base URL for the local OpenAI-compatible service
FoundryLogLevel Foundry SDK log level
OnDownloadProgress optional progress callback
AudioMode None, MultiModal, or SpeechToText
SpeechToTextModel required when AudioMode is SpeechToText
CostTracking TokenCostSettings? — when set, wraps the chat client with CostTrackingChatClient

Voice adapter

The package also registers local IVoiceAdapter support.

builder.Services.AddVoiceAdapterForFoundryLocal("foundry", settings =>
{
    settings.SttModel = "whisper";
    settings.TtsModel = "tts";
    settings.WebServiceUrl = "http://127.0.0.1:5272";
});

builder.Services.AddPlayFramework("foundry", framework =>
{
    framework.WithVoice("foundry");
});

VoiceAdapterSettings exposes:

Property Meaning
SttModel local speech-to-text model alias
TtsModel local text-to-speech model alias
TtsVoice voice name
TtsOutputFormat output format
TtsSpeed speech speed multiplier
WebServiceUrl local service URL
OnDownloadProgress optional progress callback

Cost tracking

Set CostTracking on FoundryLocalSettings to record input/output token costs per LLM call:

builder.Services.AddAdapterForFoundryLocal("foundry", settings =>
{
    settings.Model = "phi-4-mini";
    settings.CostTracking = new TokenCostSettings
    {
        Enabled = true,
        Currency = "USD",
        InputTokenCostPer1K = 0.0m,   // local models are free — set to 0 or your internal cost
        OutputTokenCostPer1K = 0.0m,
    };
});

TokenCostSettings exposes:

Property Meaning
Enabled enable or disable cost tracking, default true
Currency currency label for display, default USD
InputTokenCostPer1K cost per 1 000 input tokens
OutputTokenCostPer1K cost per 1 000 output tokens
CachedInputTokenCostPer1K cost per 1 000 cached input tokens, default 0
ModelCosts Dictionary<string, ModelCostSettings> per-model price overrides
ClientCosts Dictionary<string, ClientCostSettings> per-client price overrides

When CostTracking is set the adapter wraps the underlying IChatClient with CostTrackingChatClient — a DelegatingChatClient that reads response.Usage after every LLM call and embeds a CostCalculation into AdditionalProperties. ChatClientManager picks that value up passively and surfaces it as AiSceneResponse.Cost (per-call) and AiSceneResponse.TotalCost (cumulative across the full request).

Critical: you must call .WithChatClient("name") in AddPlayFramework with the same factory name used for the adapter. Without it the framework falls back to a direct IChatClient resolution path that does not see the cost wrapper and reports zero for all costs.


Important caveats

First resolution is heavy

The adapter performs blocking initialization, download, model loading, and service startup on first use. Treat it as a dev/test adapter rather than something that hides infrastructure startup cost.

The voice adapter assumes Foundry Local is already initialized

The voice path reads FoundryLocalManager.Instance directly. In practice, register and initialize the chat adapter before relying on AddVoiceAdapterForFoundryLocal(...).

Hardware and model availability matter

Available models depend on your platform and hardware. foundry model list is the source of truth for what your machine can actually run.

This package also targets net10.0

Like the rest of the PlayFramework area, this package currently targets net10.0.

Grounded by source files

  • src/AI/Rystem.PlayFramework.Adapters.FoundryLocal/ServiceCollectionExtensions.cs
  • src/AI/Rystem.PlayFramework.Adapters.FoundryLocal/FoundryLocalSettings.cs
  • src/AI/Rystem.PlayFramework.Adapters.FoundryLocal/VoiceAdapterSettings.cs

Use this package when you want PlayFramework backed by local Foundry models and you accept the native/runtime setup that comes with it.

Product 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. 
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
10.0.11-beta.14 56 5/13/2026
10.0.11-beta.13 73 3/27/2026
10.0.11-beta.12 62 3/27/2026
10.0.11-beta.11 65 3/25/2026
10.0.11-beta.10 64 3/23/2026
10.0.11-beta.9 57 3/20/2026
10.0.11-beta.8 58 3/19/2026
10.0.11-beta.7 60 3/18/2026
10.0.11-beta.6 61 3/17/2026
10.0.11-beta.5 66 3/16/2026
10.0.11-beta.4 67 3/16/2026
10.0.11-beta.3 62 3/5/2026
10.0.11-beta.2 66 3/4/2026