Skip to main content
Output format validators constrain structured outputs (for example validating a JSON shape after a node runs). Manage them with client.agent_validation.

Upsert from Pydantic models

Pass Pydantic classes (not instances). The client uses each class __name__ as the validator name and model_json_schema() as the JSON Schema.
from pydantic import BaseModel, Field

class Invoice(BaseModel):
    vendor: str = Field(...)
    total: float = Field(...)

result = await client.agent_validation.upsert_validators([Invoice])

Raw JSON Schema dicts

await client.agent_validation.upsert_validators([
    {"name": "Invoice", "json_schema": {"type": "object", "properties": {}}},
])

List and fetch

validators = await client.agent_validation.list_validators(limit=20)
v = await client.agent_validation.get_validator(validators.validators[0].id)
Attach validators to nodes in your agent graph configuration in the product UI or API so failed validation can trigger retries where your platform supports it.