Skip to main content
POST
/
api
/
rule-engine
/
evaluate
Evaluate Rules
curl --request POST \
  --url http://localhost:3000/api/rule-engine/evaluate \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "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
  }
}
'
{
  "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",
      "content": "You are a helpful AI assistant for premium users...",
      "status": "ACTIVE"
    }
  }
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
entity_type
enum<string>
required

Filter results to entities of this type.

Available options:
context,
prompt,
dataset,
meta_config
Example:

"context"

fields
object
required

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

Example:
{
"model": "gpt-4",
"user_tier": "premium",
"token_count": 1500
}
include_entity_data
boolean

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

Example:

true

entity_inputs
object

Extra inputs specific to the entity type. Used for prompts to control compilation.

Response

Successfully evaluated rules.

matchingRuleIds
string<uuid>[]
Example:
["a1b2c3d4-1234-5678-abcd-ef0123456789"]
entities
object[]
entity_data
object
Example:
{
"context:b2c3d4e5-2345-6789-bcde-f01234567890": {
"id": "b2c3d4e5-2345-6789-bcde-f01234567890",
"name": "Premium System Prompt",
"content": "You are a helpful AI assistant for premium users...",
"status": "ACTIVE"
}
}