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
  }
}
'
import requests

url = "http://localhost:3000/api/rule-engine/evaluate"

payload = {
"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
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
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
}
})
};

fetch('http://localhost:3000/api/rule-engine/evaluate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_PORT => "3000",
CURLOPT_URL => "http://localhost:3000/api/rule-engine/evaluate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'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
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "http://localhost:3000/api/rule-engine/evaluate"

payload := strings.NewReader("{\n \"entity_type\": \"context\",\n \"fields\": {\n \"model\": \"gpt-4\",\n \"user_tier\": \"premium\",\n \"token_count\": 1500\n },\n \"include_entity_data\": true,\n \"entity_inputs\": {\n \"variables\": {\n \"user_name\": \"Alice\",\n \"product\": \"OpenLIT\"\n },\n \"version\": \"1.0.0\",\n \"shouldCompile\": true\n }\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("http://localhost:3000/api/rule-engine/evaluate")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"entity_type\": \"context\",\n \"fields\": {\n \"model\": \"gpt-4\",\n \"user_tier\": \"premium\",\n \"token_count\": 1500\n },\n \"include_entity_data\": true,\n \"entity_inputs\": {\n \"variables\": {\n \"user_name\": \"Alice\",\n \"product\": \"OpenLIT\"\n },\n \"version\": \"1.0.0\",\n \"shouldCompile\": true\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("http://localhost:3000/api/rule-engine/evaluate")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"entity_type\": \"context\",\n \"fields\": {\n \"model\": \"gpt-4\",\n \"user_tier\": \"premium\",\n \"token_count\": 1500\n },\n \"include_entity_data\": true,\n \"entity_inputs\": {\n \"variables\": {\n \"user_name\": \"Alice\",\n \"product\": \"OpenLIT\"\n },\n \"version\": \"1.0.0\",\n \"shouldCompile\": true\n }\n}"

response = http.request(request)
puts response.read_body
{
  "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"
    }
  }
}
{
"err": "entity_type is required and must be one of: context, prompt, dataset, meta_config"
}
{
"err": "No API key provided"
}

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"
}
}