Overview
The OpenLIT SDKs provide a function to evaluate rules against the Rule Engine from your application code. At runtime, send trace attributes (model, provider, service name, etc.) and get back matching rules and their linked entities - contexts, prompts, or evaluation configurations. This enables dynamic, condition-driven retrieval of AI resources without hardcoding logic in your application.Contexts
Retrieve system prompts and knowledge based on model, user tier, or any attribute
Prompts
Fetch compiled prompts with variable substitution from the Prompt Hub
Evaluation Configs
Determine which evaluation types apply to a given trace
Prerequisites
1
Set up OpenLIT
Ensure you have an OpenLIT instance running. See Installation for setup instructions.
2
Create an API Key
Navigate to Settings > API Keys in OpenLIT. Click Create API Key and save the key securely.
3
Create Rules
Set up rules with conditions and linked entities in the Rule Engine UI.
Configuration
All SDKs resolve the OpenLIT URL and API key in the same order:Usage
Retrieve Contexts
Fetch context entities (system prompts, knowledge) that match the given trace attributes.- Python
- TypeScript
- Go
Retrieve Prompts
Fetch compiled prompts from the Prompt Hub with variable substitution.- Python
- TypeScript
- Go
Check Evaluation Rules
Determine which evaluation types (hallucination, bias, etc.) are linked to rules matching the current trace. This works with both the 11 built-in evaluation types and any custom evaluation types you have created.- Python
- TypeScript
- Go
Parameters
Python - openlit.evaluate_rule()
TypeScript - Openlit.evaluateRule()
Go - openlit.EvaluateRule()
Response Format
All SDKs return the same response structure:Error Handling
- Python
- TypeScript
- Go
Returns
None on any error (network, auth, server). Check for None before using the result.Rule Engine Guide
Learn how to create rules, add conditions, and link entities in the OpenLIT UI
API Reference
Full OpenAPI reference for the evaluate endpoint

