Ask an LLM yes/no, choice, and score questions from C# and get calibrated probabilities back as typed answers you can branch on. .NET 10 SDKs for TypeSafe AI's Jev models, the Decisions and Extractions APIs from OpenRouter and OpenAI, and Microsoft's decision models in Microsoft Foundry and Azure OpenAI.
using DecisionsDotNet;
using var client = OpenRouterDecisionsClient.FromEnvironment(); // reads OPENROUTER_API_KEY
var jev = client.ForModel("typesafe/jev-1.14");
if (await jev.MatchesAsync("My card was charged twice.", "Is the customer asking for a refund?", minProbability: 0.75))
Console.WriteLine("Route to billing");Try the live demo or run it locally.
| Package | What it does | Docs |
|---|---|---|
| DecisionsDotNet | Typed yes/no, choice, score, and bounding-box questions through TypeSafe, OpenRouter, OpenAI, Microsoft Foundry, or Azure OpenAI, with DI, batching, and bounded retries. | README |
| DecisionsDotNet.Testing | A scripted fake and a recording wrapper for IDecisionsClient, for unit tests. |
README |
| DecisionsDotNet.Caching | Caches evaluations in HybridCache as a client pipeline decorator. |
README |
| DecisionsDotNet.AI | Exposes any Decisions client as a Microsoft.Extensions.AI tool for chat clients and agents, plus chat guardrails and workflow routing. | README |
| ExtractionsDotNet | Typed field extraction from text, images, and PDFs through OpenRouter. | README |
dotnet add package DecisionsDotNet
dotnet add package DecisionsDotNet.AI
dotnet add package ExtractionsDotNetDecisionsDotNet and its add-ons (.AI, .Testing, .Caching) always share a version. ExtractionsDotNet versions on its own. See the changelog for releases and the migration from 0.3.
docs/recipes.md shows the semantic conditional verbs in ASP.NET Core endpoint filters, FluentValidation rules, and MediatR behaviors.
JevDotNet.Demo (live) is a Blazor Server app with support triage, image decisions, bulk triage, Jev as Judge, a chase game, and the Extractions Lab. It needs an OpenRouter API key:
dotnet user-secrets set "OpenRouter:ApiKey" "<your-api-key>" --project JevDotNet.Demo
dotnet run --project JevDotNet.Demodotnet test --project JevDotNet.Tests/JevDotNet.Tests.csproj
dotnet test --project JevDotNet.Demo.Tests/JevDotNet.Demo.Tests.csproj
dotnet pack DecisionsDotNet/DecisionsDotNet.csprojJevDotNet.Tests covers the three packages and JevDotNet.Demo.Tests covers the demo app.
The xUnit v3 tests use fake HTTP handlers and need no API key. The direct client follows the TypeSafe AI API reference and model listing reference.
Three checks run on every build of the packages:
- Every public member needs an XML doc comment.
- The public surface must match each package's
PublicAPI.Shipped.txtandPublicAPI.Unshipped.txt. When you change public API on purpose, updatePublicAPI.Unshipped.txtin the same commit; the IDE offers this as a quick fix on the RS0016 error. dotnet packruns package validation.
Package versions live in Directory.Build.props.
The tests in LiveSmokeTests.cs send real requests to each provider. They are skipped unless you set LIVE_TESTS=1 and the provider's settings: OPENROUTER_API_KEY, TYPESAFE_API_KEY, or OPENAI_API_KEY; for Foundry, FOUNDRY_ENDPOINT, FOUNDRY_DEPLOYMENT and FOUNDRY_API_KEY; for Azure OpenAI, AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_DEPLOYMENT and AZURE_OPENAI_API_KEY. The Foundry tests also accept FOUNDRY_DECISIONS_ENDPOINT, FOUNDRY_DECISIONS_DEPLOYMENT and FOUNDRY_DECISIONS_API_KEY, and fall back to the Azure OpenAI key; AZURE_OPENAI_APIKEY works in place of AZURE_OPENAI_API_KEY. Each request costs a fraction of a cent.
$env:LIVE_TESTS = "1"
$env:OPENROUTER_API_KEY = "<your-api-key>"
dotnet test --project JevDotNet.Tests/JevDotNet.Tests.csprojeng/verify-packages.sh packs all three packages into artifacts/nuget, then builds and runs a small console app against those files instead of the project sources. It runs on every pull request.
A release is a tag on main. DecisionsDotNet and DecisionsDotNet.AI always ship together at one version; ExtractionsDotNet versions on its own.
- Set
DecisionsVersionorExtractionsVersioninDirectory.Build.props, updateCHANGELOG.md, and merge tomain. - Tag the merge commit
decisions-v<version>orextractions-v<version>and push the tag. Tagorigin/mainafter a fetch, so a local checkout that is behind cannot put the tag on an old commit:
git fetch origin
git tag decisions-v1.0.0 origin/main
git push origin decisions-v1.0.0For a stable release, also move the entries in each package's PublicAPI.Unshipped.txt into PublicAPI.Shipped.txt in step 1.
The publish workflow fails early if the tag's version does not match Directory.Build.props or the tag is not on main. Otherwise it builds, tests, checks the packages, and pushes them to nuget.org. Running the workflow by hand from the Actions tab is a rehearsal that does everything except publish.
