Liya Engine

Defining Intents

Create custom intents with prompt templates and optional structured output schemas.

Create an intent

POST /dashboard/custom-domains/legal-ops/intents
Authorization: Bearer <dashboard_jwt>
Content-Type: application/json
 
{
  "intentKey": "contract_review",
  "displayName": "Contract Review",
  "description": "Review a contract for key obligations, risks, and missing provisions",
  "promptTemplate": "Review the following {{document_type}}.\n\nIdentify:\n1. Key obligations for each party\n2. Unusual or risky clauses\n3. Missing standard provisions\n4. Recommended amendments\n\nDocument:\n{{content}}"
}

Prompt templates

Prompt templates use {{variable}} placeholders that are replaced at request time from the input object sent by your application.

Template:

Review this {{document_type}} for compliance with {{jurisdiction}} law.

Document:
{{content}}

Request input:

{
  "document_type": "SaaS subscription agreement",
  "jurisdiction": "UK",
  "content": "This Agreement is entered into between..."
}

Any key in input can be used as a placeholder. Unknown placeholders are left as-is and visible in the output for debugging.


Calling a custom intent

Once created, the intent is immediately callable:

POST /v1/legal-ops/contract_review
x-api-key: $LIYA_API_KEY
Content-Type: application/json
 
{
  "input": {
    "user_id": "usr_123",
    "document_type": "SaaS subscription agreement",
    "content": "This Agreement is entered into between..."
  }
}

Structured output schema (optional)

To enforce a JSON output structure, provide a JSON Schema in outputSchema:

{
  "intentKey": "contract_review",
  "promptTemplate": "...",
  "outputSchema": {
    "type": "object",
    "properties": {
      "obligations": { "type": "array", "items": { "type": "string" } },
      "risk_clauses": { "type": "array", "items": { "type": "string" } },
      "missing_provisions": { "type": "array", "items": { "type": "string" } },
      "risk_level": { "type": "string", "enum": ["low", "medium", "high"] }
    },
    "required": ["risk_level"]
  }
}

When a schema is provided, the engine validates the AI output against it and returns it in data.output.structuredOutput.


Intent key rules

  • Lowercase letters, numbers, and underscores: ^[a-z0-9_]+$
  • Must be unique within the domain
  • Used as the URL path segment: /v1/{domainKey}/{intentKey}

Updating an intent

PATCH /dashboard/custom-domains/legal-ops/intents/contract_review
 
{
  "promptTemplate": "Updated prompt...",
  "description": "Updated description"
}

Updates take effect immediately on the next API call.

On this page