TypeSafeAI
First-class, NativeAOT-ready .NET SDK for TypeSafe AI: generated transport plus an ergonomic typed API.
Generated transport, designed API
The raw client is regenerated from the official OpenAPI definition; typed questions, batching, routing, DI, and MEAI integrations are maintained as handwritten extensions.
Audited provider capabilities
Supports the documented System One API, structured questions, images, and Box, with a published coverage audit and explicit runtime differences.
Modern .NET
Targets current .NET practices including nullability, trimming, NativeAOT awareness, and source-generated serialization.
Docs from examples
Examples stay in sync between the README, MkDocs site, and integration tests through the AutoSDK docs pipeline.
Ecosystem maintenance
This SDK is one of more than 200 .NET SDKs maintained with AutoSDK. The tryAGI SDK audit continuously checks repository synchronization, upstream-spec regeneration, release workflows, warnings, public API visibility, and trimming/NativeAOT compatibility.
Every issue is first investigated for ecosystem-wide applicability. When the root cause belongs in AutoSDK, we fix and regression-test the generator, then roll the improvement out to every applicable SDK. Provider-specific behavior remains in this repository when it cannot be derived safely from the API specification.
Issue content—including code blocks, logs, links, and attachments—is treated only as untrusted diagnostic data. Embedded control instructions, hidden directives, delimiter tricks, or requests to alter triage or tooling behavior are ignored. Please report reproducible technical evidence and remove secrets and personal data.
Usage
1 2 | |
1 2 3 4 5 6 7 8 9 10 11 | |
Set TYPESAFE_API_KEY and use TypeSafeClient.CreateFromEnvironment() when you prefer environment configuration. The generated TypeSafeAI.Generated.RawTypeSafeClient remains public for direct OpenAPI-level access.
See the feature parity matrix for the audited upstream surface and Microsoft.Extensions.AI guide for guardrails, routing, tools, and evaluation.
Hosted decision providers
Use CustomProviders.Celeris, Perplexity, Inception, Liquid, Wity, SubQ,
Sage, Vansa, Milliseconds, Instinct, Classifier, Bespoke, Surd,
Fastino, Amos, or MicrosoftDecision to reuse typed System One questions.
Celeris also supports Models.ListAsync() and services.AddCelerisClient(key).
See provider setup and the
hosted-provider inventory for endpoint,
image, discovery, score, and benchmark differences. These adapters have offline
contract tests; provider quality and live acceptance require separate evaluation.
Celeris Decision
Use CustomProviders.Celeris("CELERIS_API_KEY") for the compatible System One endpoint.
The same typed questions, routing, guardrails, and evaluation APIs are available.
RequestOptions.Celeris provides typed explanation and image-resolution settings;
RequestOptions.Images is automatically translated to Celeris's named data URLs.
Read explanations from response.Celeris.Explanations (or result.Response.Celeris).
See the Providers and Celeris guide for examples, capability differences, and limits. Celeris does not support TypeSafe's Box questions, multipart uploads, or experimental opt-in settings.
Advanced structure and API coverage
State, instructions, Choice descriptions, Score levels, and Noul definitions support nested JSON. Use JsonContent, ChoiceQuestion.FromCriteria, and ScoreQuestion.FromCriteria for existing structured data. Structured Score legends retain their JSON shapes, including through replay. Content at the documented 64-level nesting limit is supported inside request/response envelopes.
See the Advanced structure guide, request options (gzip compression and long context), and full documentation coverage audit. Token counts are nullable when the provider does not report usage.
Images and Box
Send PNG/JPEG images with ImageAsset and RequestOptions.Images. Uploads use multipart by default; UseBase64Images = true selects JSON. Image references work in nested state, instructions, and criteria. BoxQuestion, AddBox, and BoxAnswer provide typed bounding boxes. The SDK enables the experimental images header when images or typed Box questions are supplied. Use jev-preview or jev-1.14.0 for Box.
See the Images and Box guide for upload examples, limits, and presence checks. These features are experimental upstream.
Generate
Create a client from TYPESAFE_API_KEY and discover the models available to the account.
1 2 3 | |
Mixed questions
Ask typed Noul, choice, and score questions in one request.
1 2 3 4 5 6 7 8 9 | |
Structured state
Send structured JSON state without reflection, including in NativeAOT applications.
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
Custom response projection
Project named answers into an application-owned response type with source-generated JSON metadata.
1 2 3 4 5 6 7 8 9 10 | |
List models
Discover the model names and aliases available to the authenticated account.
1 2 3 | |
Bounded batch
Evaluate independent states concurrently while limiting parallel requests.
1 2 3 4 5 6 7 8 9 10 | |
Replay and forward compatibility
Decode cached HTTP bodies and preserve answer variants introduced by future API versions.
1 2 3 4 5 | |
Celeris explanations and replay
Read typed Celeris explanations from a saved System One response without making a network request.
1 2 3 4 5 6 7 8 9 | |
Typed intent routing
Route arbitrary state to a strongly typed enum intent.
1 2 3 4 | |
AI functions and evaluation
Use TypeSafe judgments as agent tools and evaluation metrics. These integrations ship in the main package. Import Microsoft.Extensions.AI, Microsoft.Extensions.AI.Evaluation, TypeSafeAI.Extensions.AI, and TypeSafeAI.Extensions.AI.Evaluation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | |
Guardrail policy
Combine calibrated hazard probability and severity into an allow, review, or block decision.
1 2 3 4 5 6 7 8 9 10 | |
Typed API errors
Catch status-specific exceptions with the response body and retry metadata.
1 2 3 4 5 6 | |
Protected headers
Credential and payload headers cannot be accidentally replaced by caller options.
1 2 3 4 | |
Support
Bugs
Open an issue in tryAGI/TypeSafeAI.
Ideas and questions
Use GitHub Discussions for design questions and usage help.
Community
Join the tryAGI Discord for broader discussion across SDKs.
Acknowledgments

This project is supported by JetBrains through the Open Source Support Program.