> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tai42.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Schema forms

> The schema-driven form renderer and the JSON Schema helpers it is built on.

The schema-driven form renderer and the JSON Schema helpers it is built on.

## CompletionProvider

```ts theme={null}
type CompletionProvider = (argName: string, partial: string) => Promise<string[]>
```

Fetch argument-value suggestions for a string field. `argName` is the field's
path within the form (a property key at the root, a dotted path when nested);
`partial` is the value typed so far. The caller owns the source (e.g. an MCP
`completion/complete` call) — SchemaForm only routes string fields through the
completion-backed input when a provider is supplied.

## Discriminator

```ts theme={null}
interface Discriminator
```

A Pydantic-style discriminated-union tag: which property selects the variant.

**Properties**

| Property       | Type                               | Description |
| -------------- | ---------------------------------- | ----------- |
| `mapping?`     | `Readonly<Record<string, string>>` | —           |
| `propertyName` | `string`                           | —           |

## JsonSchema

```ts theme={null}
interface JsonSchema
```

A structural JSON Schema node. All keys optional; the index signature keeps
the type permissive so an unrecognized keyword is never a type error — it is a
runtime classification concern the renderer handles.

**Properties**

| Property                | Type                                          | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ----------------------- | --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `$defs?`                | `Readonly<Record<string, JsonSchema>>`        | —                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `$ref?`                 | `string`                                      | —                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `additionalProperties?` | `boolean \| JsonSchema`                       | —                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `allOf?`                | `readonly JsonSchema[]`                       | —                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `anyOf?`                | `readonly JsonSchema[]`                       | —                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `const?`                | `unknown`                                     | —                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `contentEncoding?`      | `string`                                      | Media annotations (see the `SchemaForm` module). `contentEncoding: "base64"` together with `contentMediaType` (or `format: "data-url"`) opts a string field into the upload control; `contentMaxBytes` pins a per-field size cap.  `contentMaxBytes` is a NONSTANDARD JSON-Schema extension keyword — a standard JSON-Schema validator ignores it. The client-side caps it drives (see the `media` module) are UX guards, NOT a security boundary: the SERVER MUST independently validate the decoded size of any uploaded content. |
| `contentMaxBytes?`      | `number`                                      | —                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `contentMediaType?`     | `string`                                      | —                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `default?`              | `unknown`                                     | —                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `definitions?`          | `Readonly<Record<string, JsonSchema>>`        | —                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `description?`          | `string`                                      | —                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `discriminator?`        | `Discriminator`                               | —                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `enum?`                 | `readonly unknown[]`                          | —                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `format?`               | `string`                                      | —                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `items?`                | `JsonSchema`                                  | —                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `maxItems?`             | `number`                                      | —                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `maxLength?`            | `number`                                      | —                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `maximum?`              | `number`                                      | —                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `minItems?`             | `number`                                      | —                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `minLength?`            | `number`                                      | —                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `minimum?`              | `number`                                      | —                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `oneOf?`                | `readonly JsonSchema[]`                       | —                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `properties?`           | `Readonly<Record<string, JsonSchema>>`        | —                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `required?`             | `readonly string[]`                           | —                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `title?`                | `string`                                      | —                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `type?`                 | `JsonSchemaType \| readonly JsonSchemaType[]` | —                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |

**Related:** [Discriminator](/reference/studio-sdk/schema-forms#discriminator), [JsonSchemaType](/reference/studio-sdk/schema-forms#jsonschematype)

## JsonSchemaType

```ts theme={null}
type JsonSchemaType = "string" | "number" | "integer" | "boolean" | "object" | "array" | "null"
```

The JSON-Schema `type` keyword values Pydantic emits.

## SchemaForm

```ts theme={null}
function SchemaForm(props: SchemaFormProps): ReactNode
```

Render a controlled form for `schema`. The root is usually an object (a tool's
input schema); a scalar/array/union root renders as a single field group.

**Props**

| Prop                  | Type                               | Description                                                                                                                                                                                                   |
| --------------------- | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `completionProvider?` | `CompletionProvider`               | Optional. When supplied, every string field renders through the completion-backed input (argument autocomplete); when omitted, string fields render as a plain text input — the default, unchanged behaviour. |
| `errors?`             | `Readonly<Record<string, string>>` | —                                                                                                                                                                                                             |
| `idPrefix?`           | `string`                           | —                                                                                                                                                                                                             |
| `maxUploadBytes?`     | `number`                           | Optional. Default byte cap for media-upload fields (see the module doc-comment). A field's own `contentMaxBytes` annotation overrides it; absent both, DEFAULT\_MAX\_UPLOAD\_BYTES applies.                   |
| `onChange`            | `(value: unknown) => void`         | —                                                                                                                                                                                                             |
| `schema`              | `JsonSchema`                       | —                                                                                                                                                                                                             |
| `value`               | `unknown`                          | —                                                                                                                                                                                                             |

**Related:** [SchemaFormProps](/reference/studio-sdk/schema-forms#schemaformprops)

## SchemaFormErrors

```ts theme={null}
type SchemaFormErrors = Readonly<Record<string, string>>
```

A structured, per-path bag of validation problems. Keys are dotted/bracketed
paths from the form root (`""` = the root value, `"user.name"`, `"tags[0]"`);
each entry is a loud, human-readable message. Empty object = valid.

## SchemaFormProps

```ts theme={null}
interface SchemaFormProps
```

**Properties**

| Property              | Type                               | Description                                                                                                                                                                                                   |
| --------------------- | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `completionProvider?` | `CompletionProvider`               | Optional. When supplied, every string field renders through the completion-backed input (argument autocomplete); when omitted, string fields render as a plain text input — the default, unchanged behaviour. |
| `errors?`             | `Readonly<Record<string, string>>` | —                                                                                                                                                                                                             |
| `idPrefix?`           | `string`                           | —                                                                                                                                                                                                             |
| `maxUploadBytes?`     | `number`                           | Optional. Default byte cap for media-upload fields (see the module doc-comment). A field's own `contentMaxBytes` annotation overrides it; absent both, DEFAULT\_MAX\_UPLOAD\_BYTES applies.                   |
| `onChange`            | `(value: unknown) => void`         | —                                                                                                                                                                                                             |
| `schema`              | `JsonSchema`                       | —                                                                                                                                                                                                             |
| `value`               | `unknown`                          | —                                                                                                                                                                                                             |

**Related:** [CompletionProvider](/reference/studio-sdk/schema-forms#completionprovider), [JsonSchema](/reference/studio-sdk/schema-forms#jsonschema)

## defaultValueForSchema

```ts theme={null}
function defaultValueForSchema(schema: JsonSchema, root: JsonSchema): unknown
```

The initial value for a schema. `root` carries the `$defs` document for
`$ref` resolution and defaults to the schema itself (the common
whole-tool-schema call).

**Parameters**

| Parameter | Type         | Default  | Description |
| --------- | ------------ | -------- | ----------- |
| `schema`  | `JsonSchema` | —        | —           |
| `root`    | `JsonSchema` | `schema` | —           |

**Related:** [JsonSchema](/reference/studio-sdk/schema-forms#jsonschema)

## resolveRef

```ts theme={null}
function resolveRef(schema: JsonSchema, root: JsonSchema): JsonSchema
```

Resolve an internal `$ref` against the document root, following chained refs
(a `$ref` whose target is itself a `$ref`). Only same-document pointers are
supported (`#/$defs/Name`, `#/definitions/Name`, `#`); an external or
unresolvable ref throws LOUDLY rather than yielding a silent empty schema.
A schema with no `$ref` is returned unchanged. A pointer cycle throws.

**Parameters**

| Parameter | Type         | Default | Description |
| --------- | ------------ | ------- | ----------- |
| `schema`  | `JsonSchema` | —       | —           |
| `root`    | `JsonSchema` | —       | —           |

**Related:** [JsonSchema](/reference/studio-sdk/schema-forms#jsonschema)

## validateAgainstSchema

```ts theme={null}
function validateAgainstSchema(
  schema: JsonSchema,
  value: unknown,
  options?: ValidateOptions,
): SchemaFormErrors
```

Validate `value` against `schema`, returning a per-path error bag (empty =
valid). The caller runs this before submit and feeds the result back to
`SchemaForm` for display. `options.maxUploadBytes` mirrors the renderer's
`maxUploadBytes` prop so a media field's byte cap is enforced identically here.

**Parameters**

| Parameter              | Type              | Default | Description |
| ---------------------- | ----------------- | ------- | ----------- |
| `schema`               | `JsonSchema`      | —       | —           |
| `value`                | `unknown`         | —       | —           |
| `options` *(optional)* | `ValidateOptions` | —       | —           |

**Related:** [JsonSchema](/reference/studio-sdk/schema-forms#jsonschema), [SchemaFormErrors](/reference/studio-sdk/schema-forms#schemaformerrors)
