Structured Output: JSON / Function Calling

AI Navigate Original / 5/16/2026

共有:

Key Points

  • Apps need machine-processable structured output, not free text
  • Use schema JSON or Function Calling; execution stays yours
  • Schema-validate, forbid extra text, fix enums, validate args
  • Validate + retry; Function Calling receives intent, not execution

Structured Output: JSON / Function Calling

In apps, machine-processable structured output, not free text, is essential. Use JSON output or Function/Tool Calling.

Means

  • Schema-specified JSON output: define types and required fields and have it return them
  • Function/Tool Calling: have the model output "the function and arguments to call"; execution is your own

Hardening Points

  1. Schema-validate output: reject broken JSON, retry/fallback
  2. Instruct against extra preamble/code fences
  3. Fix enum values (don't allow free-form)
  4. Always validate arguments before function execution (don't trust the model)

Caution

  • "Return as JSON" alone breaks. Design presuming validation + retry
  • Function Calling is "receive intent," not "delegate execution." People/code judge whether to execute

Key Point

Structured output is "the glue to embed an LLM in a program." Don't trust without validation—that's the premise of stable operation.