Repository navigation
The first release of a C# sample for the Azure OpenAI Decisions API, now generally available in Microsoft Foundry.
Instead of generating text, the Decisions API returns typed answers your code can branch on. This sample sends one support ticket and asks three questions in a single request.
What's included
- Predicate question: the probability that the customer is asking for a refund
- Choice question: which department should handle the ticket (billing, technical, shipping or other), with a confidence
- Score question: severity on a three-level rubric (Cosmetic, Workaround available, Fully blocked), with a confidence
- Refusal handling: a refusal is treated as its own answer type and sent to a person, not read as a low probability
- Two ways to sign in: an API key, or Entra ID through
DefaultAzureCredential(az loginlocally) - No SDK needed: plain
HttpClientagainstPOST /openai/v1/decisions - Settings in user secrets: no keys or endpoints in code
- Build workflow: GitHub Actions builds the project on every push and pull request
Example output
refund_requested: 100% true
department: billing (confidence 100%)
severity: 0.98 (confidence 13%)
The 13% confidence on severity is the signal to send the ticket to a person.
Requirements
- .NET 10 SDK
- An Azure OpenAI resource with a
gpt-6-lunadeployment (currently the only model the Decisions API supports) - An API key, or the Cognitive Services OpenAI User role for Entra ID
Get started
git clone https://github.com/taswar/OpenAI-DecisionApi-CSharp-Sample.git
cd OpenAI-DecisionApi-CSharp-Sample
dotnet run
See the README for configuration and troubleshooting.
Learn more
- 📖 Full walkthrough: Decisions API in Azure OpenAI: A C# Walkthrough
- 🔁 Companion sample: Microsoft-Decision-1 C# Demo
⭐ If this saved you time, star the repo so other .NET developers can find it.