Rystem.PlayFramework.Adapters.FoundryLocal
10.0.11-beta.14
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
<PackageReference Include="Rystem.PlayFramework.Adapters.FoundryLocal" Version="10.0.11-beta.14" />
<PackageVersion Include="Rystem.PlayFramework.Adapters.FoundryLocal" Version="10.0.11-beta.14" />
<PackageReference Include="Rystem.PlayFramework.Adapters.FoundryLocal" />
paket add Rystem.PlayFramework.Adapters.FoundryLocal --version 10.0.11-beta.14
#r "nuget: Rystem.PlayFramework.Adapters.FoundryLocal, 10.0.11-beta.14"
#:package Rystem.PlayFramework.Adapters.FoundryLocal@10.0.11-beta.14
#addin nuget:?package=Rystem.PlayFramework.Adapters.FoundryLocal&version=10.0.11-beta.14&prerelease
#tool nuget:?package=Rystem.PlayFramework.Adapters.FoundryLocal&version=10.0.11-beta.14&prerelease
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:
- initialize
FoundryLocalManager - query the local model catalog
- download the selected model if needed
- load the model into memory
- start the local OpenAI-compatible web service
- create an
IChatClientagainst{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")inAddPlayFrameworkwith the same factory name used for the adapter. Without it the framework falls back to a directIChatClientresolution 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.cssrc/AI/Rystem.PlayFramework.Adapters.FoundryLocal/FoundryLocalSettings.cssrc/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 | 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. |
-
net10.0
- Microsoft.AI.Foundry.Local (>= 1.1.0)
- Microsoft.Extensions.AI.OpenAI (>= 10.6.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.8)
- Rystem.PlayFramework (>= 10.0.11-beta.14)
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 |