v1

latestOpenAPI 3.0.02026-07-26809.1 KB

Evaluate Rules

Evaluates all active rules against the provided input fields and returns matching rule IDs, linked entities, and optionally their full data.

post/api/rule-engine/evaluate

Request body

entity_type'context' | 'prompt' | 'evaluation' required

Filter results to entities of this type.

fieldsobject required

Key-value map of input values to evaluate against rule conditions.

include_entity_databoolean

When true, fetches full entity records and includes them in entity_data.

Example request

{
  "entity_type": "context",
  "fields": {
    "model": "gpt-4",
    "user_tier": "premium",
    "token_count": 1500
  },
  "include_entity_data": true,
  "entity_inputs": {
    "variables": {
      "user_name": "Alice",
      "product": "OpenLIT"
    },
    "version": "1.0.0",
    "shouldCompile": true
  }
}

Response

Successfully evaluated rules.

matchingRuleIdsstring[]
entity_dataobject

Full entity records, keyed as "entity_type:entity_id". Only populated for context and prompt entity types today - evaluation entities never populate entity_data.

Example response

{
  "matchingRuleIds": [
    "a1b2c3d4-1234-5678-abcd-ef0123456789"
  ],
  "entities": [
    {
      "rule_id": "a1b2c3d4-1234-5678-abcd-ef0123456789",
      "entity_type": "context",
      "entity_id": "b2c3d4e5-2345-6789-bcde-f01234567890"
    }
  ],
  "entity_data": {
    "context:b2c3d4e5-2345-6789-bcde-f01234567890": {
      "id": "b2c3d4e5-2345-6789-bcde-f01234567890",
      "name": "Premium System Prompt",
      "description": "System prompt used for premium-tier users on gpt-4",
      "content": "You are a helpful AI assistant for premium users...",
      "tags": [
        "premium",
        "system"
      ],
      "meta_properties": {
        "model": "gpt-4",
        "region": "us"
      },
      "status": "ACTIVE",
      "created_by": "jane@example.com",
      "created_at": "2026-01-15T10:32:00Z",
      "updated_at": "2026-02-01T08:10:00Z"
    }
  }
}