In this section, we will see how to use the methods of the client.schemas module. Please check the API Reference for more details.
The Schema class turns a design-time schema that you supply (JSON Schema or Pydantic model) into all the artefacts required to obtain, validate and post-process a large-language-model (LLM) extraction:
A system prompt
An inference-time schema
Copy
{ "X-SystemPrompt": "You are a useful assistant extracting information from documents.", "properties": { "name": { "description": "The name of the calendar event.", "title": "Name", "type": "string" }, "date": { "X-ReasoningPrompt": "The user can mention it in any format, like **next week** or **tomorrow**. Infer the right date format from the user input.", "description": "The date of the calendar event in ISO 8601 format.", "title": "Date", "type": "string" } }, "required": [ "name", "date" ], "title": "CalendarEvent", "type": "object"}
Ingests a schema specifying the data structure you want to extract (JSON Schema or Pydantic Model).
Produces A system prompt and unfolds the reasoning fields into a new data structure that will be used when calling the LLM.
This design allows to separate the inference logic from the clean business object you ultimately use. It minimises boilerplate while keeping every transformation explicit and auditable.
from uiform import Schemaschema_obj = Schema( json_schema = { 'X-SystemPrompt': 'You are a useful assistant.', 'properties': { 'name': { 'description': 'The name of the calendar event.', 'title': 'Name', 'type': 'string' }, 'date': { 'description': 'The date of the calendar event in ISO 8601 format.', 'title': 'Date', 'type': 'string' } }, 'required': ['name', 'date'], 'title': 'CalendarEvent', 'type': 'object' })
from uiform import Schemafrom pydantic import BaseModel, Field, ConfigDictclass CalendarEvent(BaseModel): model_config = ConfigDict(json_schema_extra = {"X-SystemPrompt": "You are a useful assistant."}) name: str = Field(..., description="The name of the calendar event." ) date: str = Field(..., description="The date of the calendar event in ISO 8601 format.", )schema_obj = Schema( pydantic_model = CalendarEvent)
The Generate Schema endpoint allows you to automatically generate a JSON Schema from a set of example documents. This is particularly useful when you want to create a schema that captures all the important fields and patterns present in your documents.
You can provide multiple documents to ensure the generated schema covers all possible variations in your data structure. The AI will analyze the documents and create a comprehensive schema with appropriate field descriptions and validation rules.
Copy
from uiform import UiFormuiclient = UiForm()schema_obj = uiclient.schemas.generate( modality = "native", model = "gpt-4.1", temperature = 0, stream = False, documents = [ "freight/booking_confirmation_1.jpg", "freight/booking_confirmation_2.jpg" ])