Skip to content

feat(generation): add structured JSON generation helpers #126

@leehack

Description

@leehack

Feature description

Add high-level helpers for structured JSON generation, building on the existing grammar/GBNF capabilities.

Motivation

Many app integrations need reliable machine-readable output. Users should not have to manually write grammars or prompt wrappers for common JSON-object / JSON-schema use cases.

Proposed scope

  • Provide an ergonomic API for strict JSON-object generation.
  • Consider JSON Schema to grammar/GBNF conversion for a practical MVP subset.
  • Add validation and helpful errors when a schema cannot be represented safely.
  • Make the helper compatible with streaming where possible, or clearly document limitations.
  • Include examples for extraction/classification-style app tasks.

Related work

Acceptance criteria

  • Public API docs explain supported schema features and limitations.
  • Examples demonstrate generating typed JSON and validating the final output.
  • Tests cover success, invalid schema, and malformed model-output cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions