Skip to main content

Understand Struct

Struct is Blatent’s model for structured decisions. It turns messages, documents and other input into constrained JSON: extracted fields, classifications, chosen actions or generated content.

Start with input and a JSON Schema. Add application state for facts your backend knows, and policies for additional rules the answer must satisfy.

Input: the material to interpret​

The input field holds the material to interpret: messages, documents, logs or formatted text such as XML, YAML or Markdown. Send text as a string in the JSON request body, or pass a JSON value directly.

Schema: the answer to generate​

Send a JSON Schema in schema to define the output fields, types and constraints. Field descriptions guide Struct's interpretation; schema rules restrict the allowed values. For example, an enum limits a support category to “billing”, “technical” or “other”, while its description explains how to choose.

State: facts your application supplies​

The optional state field is a JSON object of application facts supplied alongside the input. For example, send a customer's refund request in input and the order's payment status in state.

State provides context. To enforce restrictions, Struct's schema extensions under x-runtime can use those facts to limit choices, such as making refund approval unavailable for an unpaid order.

Policy: additional rules the answer must satisfy​

The optional policy field adds rules for the answer, such as requiring a total to equal the sum of its line items. Struct evaluates them with Open Policy Agent (OPA), a policy engine. You write the rules in its language, Rego.

If a candidate fails a policy, Struct searches for alternatives within the configured budget. It returns a compliant answer, or an error if none is found.

The response​

The API returns a JSON object with the generated answer in output, alongside metadata such as usage. Your schema applies to the value inside output.

A successful answer satisfies the supported schema constraints and any attached policy. Evaluate its interpretation accuracy too: an allowed category can still be the wrong classification.

Where Struct fits​

Struct is an LLM built for software that needs fast, accurate generation at low cost. It combines interpretation with enforceable output rules, so your application controls what it can return.

It shines in high-volume extraction, classification, workflow routing and constrained content generation, where latency, cost and predictable behavior matter on every request.

Find a guide​

Start with your first request, or jump to a feature below. Each guide stands alone, with files and request examples in Python, TypeScript and cURL.

Browse worked examples for complete use cases, or the resolve reference for request and response details.