schema_constructors: Schema constructors for structured outputs

schema_constructorsR Documentation

Schema constructors for structured outputs

Description

Build JSON Schema field definitions for use with foundry_schema() or raw schema lists passed to foundry_extract() and foundry_response().

Usage

schema_string(description = NULL, enum = NULL)

schema_enum(values, description = NULL)

schema_number(description = NULL)

schema_integer(description = NULL)

schema_boolean(description = NULL)

schema_array(items, description = NULL, min_items = NULL, max_items = NULL)

schema_object(
  ...,
  required = NULL,
  additional_properties = FALSE,
  description = NULL
)

Arguments

description

Character. Optional field description.

enum

Character vector of allowed values.

values

Character vector of allowed values for schema_enum().

items

List. Item schema for schema_array().

min_items, max_items

Integer. Optional array length bounds.

...

Named child fields for schema_object().

required

Character vector of required child fields. Defaults to all supplied fields.

additional_properties

Logical. Whether undeclared object properties are allowed.

Value

A JSON Schema fragment represented as an R list.

Examples

schema_string("Free-text label")
schema_enum(c("positive", "negative", "neutral"))
schema_object(
  sentiment = schema_enum(c("positive", "negative", "neutral")),
  confidence = schema_number()
)

foundryR documentation built on Sept. 25, 2026, 1:10 a.m.