> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openlit.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Rule Engine for Conditional Prompt & Context Retrieval

> Rule Engine is a rules engine for conditional AI resource retrieval — define matching conditions once and ask what applies at runtime.

Rule Engine lets you define matching conditions once, instead of hardcoding lookup logic like "if model is X, use prompt Y" throughout your application. A rule pairs a set of conditions on runtime fields - like the model being called, the deployment environment, or the cost of a request - with the resources that should come back when those conditions are met. Your application calls a single API to ask "what applies right now?", and OpenLIT itself uses the same mechanism when retrieving a [Context](https://docs.openlit.io/latest/openlit/prompts-experiments/context/overview.md) or [Prompt](https://docs.openlit.io/latest/openlit/prompts-experiments/prompt-hub/overview.md) that's linked to a matching rule.

> [card] [Create & Manage Rules](https://docs.openlit.io/latest/openlit/prompts-experiments/rule-engine/create-and-manage-rules.md)
>
> Create a rule from the dialog, edit its details, and delete rules you no longer need

> [card] [Conditions](https://docs.openlit.io/latest/openlit/prompts-experiments/rule-engine/conditions.md)
>
> Build condition groups, pick fields and operators, and combine groups with AND/OR

> [card] [Preview](https://docs.openlit.io/latest/openlit/prompts-experiments/rule-engine/preview.md)
>
> Sanity-check a rule's saved conditions against your last 100 traces before relying on it

> [card] [Linked Entities](https://docs.openlit.io/latest/openlit/prompts-experiments/rule-engine/linked-entities.md)
>
> Connect a rule to a Context, Prompt, or Evaluation Type so a match returns real resources

> [card] [Evaluate API](https://docs.openlit.io/latest/openlit/prompts-experiments/rule-engine/evaluate-api.md)
>
> Call the evaluate endpoint from any application with a Bearer API key

## Frequently asked questions

> [accordion] What is the Rule Engine used for?
>
> Rule Engine matches runtime inputs - like model name, deployment environment, or cost - against conditions you define, then returns the Context, Prompt, or Evaluation Type linked to any rule that matches. This lets your application (or OpenLIT itself) look up the right resource for the current situation instead of hardcoding that logic in code.

> [accordion] What kinds of resources can a rule return?
>
> A rule can be linked to a Context, a Prompt, or an Evaluation Type. When the rule matches, all of its linked entities are returned, and their full data can be included in the response if you ask for it.

> [accordion] Can I call the Rule Engine from outside OpenLIT?
>
> Yes. The evaluate API accepts a Bearer API-key token, so any application can evaluate rules and retrieve linked entities without a dashboard session. See the [Evaluate API](https://docs.openlit.io/latest/openlit/prompts-experiments/rule-engine/evaluate-api.md) page.

> [accordion] How are multiple conditions combined?
>
> Conditions are organized into groups, each with its own AND/OR logic. The groups themselves are then combined using the rule's top-level Group Operator, so you can express nested matching logic without writing any code. See [Conditions](https://docs.openlit.io/latest/openlit/prompts-experiments/rule-engine/conditions.md) for details.

***

> [card] [Context](https://docs.openlit.io/latest/openlit/prompts-experiments/context/overview.md)
>
> Store reusable knowledge and system instructions that can be retrieved when rules match

> [card] [Prompt Hub](https://docs.openlit.io/latest/openlit/prompts-experiments/prompt-hub/overview.md)
>
> Version, deploy, and collaborate on prompts with centralized management and tracking

> [card] [SDK Rule Engine](https://docs.openlit.io/latest/sdk/features/rule-engine.md)
>
> Use evaluate\_rule() from Python, TypeScript, or Go with full parameter reference and examples

> [card] [API Reference: Evaluate](https://docs.openlit.io/latest/openlit/developer-resources/api-reference/endpoint/rule-engine/evaluate.md)
>
> Full reference for the Rule Engine evaluate endpoint with request and response schemas


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.