TOON (Token-Oriented Object Notation) is a compact, schema-aware textual format well suited to uniform tables. AI Kit can auto-generate TOON prompts and parse the responses back into yourDocumentation Index
Fetch the complete documentation index at: https://ai.aidalinfo.fr/llms.txt
Use this file to discover all available pages before exploring further.
structuredOutput schema.
Why TOON?
- 30–60 % fewer tokens compared to pretty-printed JSON for tabular payloads.
- Explicit schema header (
collection[length]{fields}) acts as a guardrail for the model. - Single code path for generation + parsing thanks to
@toon-format/toon. - Decoder now coerces numeric tokens into strings when the schema expects strings (handy for IDs such as SIRET/SIREN).
Enabling TOON
TOON requires astructuredOutput schema. Once provided, you can enable the format either globally on the agent or per request.
Default on an agent
Override per call
You can still opt out (or in) on a specific call:toon: true next to structuredOutput.
Prompt behavior
When TOON is enabled, AI Kit:- Builds a schema example from your
structuredOutputand injects it into the system prompt inside a ```toon block. - Instructs the model to produce only that block, keeping
[N]equal to the number of rows. - Parses the response with
@toon-format/toon, coerces numeric literals into strings when the schema wants strings, and finally validates via Zod.
AI_NoObjectGeneratedError.
Limitations & tips
agent.streamdoes not support TOON yet—stick toagent.generate.- Always pass a
structuredOutput; TOON is ignored otherwise. - Keep short instructions telling the model how to reference the TOON block (e.g., “quote IDs exactly as shown”).
- Log token savings by comparing
JSON.stringifylength with the resulting TOON block to measure impact. - Need raw conversion utilities? Use the upstream
@toon-format/toonpackage or CLI locally.