TypeLLM makes JSON Schema part of LLM decoding
TypeLLM constrains token selection so an LLM returns booleans, numbers, strings, and enumerated values that match a supported subset of JSON Schema. The Apache-2.0 project combines an SGLang server with a Python client and supports optional reasoning before the typed answer.
Malformed JSON, invalid enum values, and inconsistent scalar formats often force applications to add parsing, repair, and retry logic. TypeLLM enforces the declared type during generation and returns Python values that application code can consume directly. The guarantee covers structure and allowed values; factual accuracy still depends on the model and prompt.
Types become decoding rules
Developers provide shared context and describe the fields they need. At each decoding step, the server restricts the available vocabulary to tokens that can continue a valid value for the field's declared type.
Boolean and enum fields cannot produce an undeclared option, which removes an entire class of downstream validation failures. Open-ended strings and numbers retain variable-length generation while remaining constrained by their supported type rules.