TypeChat is a library that makes it easy to build natural language interfaces using types.
Building natural language interfaces traditionally required complex decision trees and prompt engineering to constrain model outputs and ensure valid responses. TypeChat replaces prompt engineering with schema engineering by letting developers define types representing the intents their application supports. These types can be simple interfaces for sentiment categorization or complex structures for shopping carts and music applications. Developers extend functionality by adding types to discriminated unions, and can create hierarchical schemas using meta-schemas to select sub-schemas based on user input. The library then handles constructing prompts to the LLM, validating responses against the schema, repairing non-conforming output through further model interaction, and summarizing results to confirm alignment with user intent.
TypeChat suits developers building conversational applications who want to move away from fragile prompt engineering toward declarative type definitions. The approach works across TypeScript, Python, and C#/.NET, with example projects available to explore. The library is particularly valuable when you need structured, validated outputs from language models without the maintenance burden of hand-crafted prompts.
The project maintains active engagement with contributions and pull requests, indicating ongoing development and community involvement. Documentation is actively maintained with examples and getting started guides readily available. The codebase spans multiple language implementations, suggesting sustained effort to support developers across different technology stacks.