Skip to content

Structured output fields

create_prompt / update_prompt take an optional fields: a list of field defs. When fields is set, the prompt runs as structured extraction instead of free-text generation — run_prompt / test_prompt return typed data, and text (if given) becomes the extraction instructions. Each field is an object with at least name and field_type. Valid field_type:

  • text, date, datetime, yes_no, whole_number, money
  • choice — also requires a choices list of allowed values.

Example:

[
{"name": "invoice_total", "field_type": "money"},
{"name": "due_date", "field_type": "date"},
{"name": "priority", "field_type": "choice", "choices": ["low", "high"]}
]

Passing fields to update_prompt creates a new revision. post_processing_instructions (also on create_prompt/update_prompt) runs a second refinement call over the extracted data — useful for cleanup or cross-field derivation that needs the full first-pass result in context.