TypeChat logo

TypeChat

Free

TypeChat is a library that makes it easy to build natural language interfaces using types. ![GitHub Repo stars](https://img.shields.io/github/stars/microsoft/TypeChat?style=social)

FreeFree tier
Type
Open Source
Company
Microsoft

About TypeChat

TypeChat is a library by Microsoft that simplifies building natural language interfaces by using TypeScript types (or types in other supported languages) as schemas. Instead of complex prompt engineering, developers define types representing the intents of their application. TypeChat then constructs prompts for large language models (LLMs) based on those types, validates that the LLM's response conforms to the schema, automatically repairs non-conforming output through further LLM interaction, and summarizes the result without needing an LLM. It supports TypeScript/JavaScript, Python, and C#/.NET, and is open source hosted on GitHub with over 8,700 stars.

Key Features

Replaces prompt engineering with schema engineering using developer-defined types
Automatically constructs prompts for LLMs based on type definitions
Validates LLM responses conform to the provided schema
Repairs non-conforming output through further language model interaction
Summarizes results without requiring an LLM call
Supports TypeScript/JavaScript, Python, and C#/.NET
Open source under Microsoft's GitHub repository

Pros & Cons

Pros
  • Reduces complexity and fragility of prompt engineering
  • Ensures LLM output is safe and structured via type validation
  • Automatic repair of invalid responses without manual intervention
  • Free and open source with permissive license
  • Supports multiple programming languages (TypeScript, Python, C#)
Cons
  • Requires upfront effort to define types/schemas for all intents
  • Still depends on LLM availability and can incur API costs
  • Limited to scenarios where intents can be described by types
  • May not handle highly ambiguous or unstructured inputs well

Best For

Categorizing sentiment from natural language inputBuilding intent-based shopping cart or music application interfacesCreating structured decision trees from user queriesExtracting typed data from conversational interfaces

FAQ

What is TypeChat?
TypeChat is a library that makes it easy to build natural language interfaces using types. It replaces prompt engineering with schema engineering by letting developers define types for intents and then handling prompt construction, validation, and repair.
What languages does TypeChat support?
TypeChat currently supports TypeScript/JavaScript, Python, and C#/.NET.
How does TypeChat handle invalid LLM responses?
If the LLM's response does not conform to the defined schema, TypeChat automatically repairs it through further language model interaction until it matches the expected types.
Is TypeChat free?
Yes, TypeChat is open source and free to use. You can install it via npm for TypeScript/JavaScript or use it from source for Python and C#.
Who created TypeChat?
TypeChat was created by Microsoft and is hosted on their GitHub repository.