Beyond JSON mode
JSON mode works because the provider hard-codes the JSON grammar into decoding. Your DSL isn't in that list, so 'structured output' features don't cover it — they'll happily return a string that your parser then rejects.
dslai treats your grammar the way JSON mode treats JSON: as a decoding constraint. The model's output is forced to be a member of your language, so structure is guaranteed for the format you actually use, not just the ones that shipped.
Guarantee, then verify
Constrained generation makes the output valid; the deterministic validator proves it and gives an exact error on anything that didn't come from the constrained path — hand-written DSL in a pull request, say. Together they give the same confidence for your DSL that JSON schema validation gives for JSON.
It all flows from one grammar, so there's a single source of truth for what 'valid' means across generation and validation.
frequently asked
- How is this different from JSON mode or function calling?
- Those guarantee structure only for JSON-shaped output. dslai guarantees structure for any language you express as a grammar, including custom DSLs and config dialects.
- Can I use it for config files, query languages, or rule languages?
- Yes — alert rules, route guards, typed key=value config, small query languages, anything with a grammar. The playground ships examples of several.
- Does the model still get to make real choices?
- Yes. The constraint only removes options that would break the grammar; the model freely chooses among the valid ones, so content is still the model's, just always well-formed.
- Where can I try it?
- The dslai playground runs the constraint and the validator in your browser, free and without an account, so you can paste your grammar and see guaranteed-valid output immediately.
Last updated June 7, 2026