Python SDK: Integrations reference | API: Evaluation endpoint
The problem it solves
Without middleware, adding responsible-AI checks to every LLM call means writing evaluation code in every place you call the LLM, duplicating logic, risking coverage gaps, and cluttering your application code:How it works
When you call a method on the RAIL wrapper, three things happen transparently:- Your messages are forwarded to the underlying LLM API as a normal API call.
- The LLM response is submitted to the RAIL evaluation endpoint in the mode you configured.
- A wrapped response object is returned containing the original content, RAIL score, per-dimension scores, and a
threshold_metboolean, all in one return value.
Supported providers
| Wrapper | Wraps | Python | JavaScript |
|---|---|---|---|
RAILOpenAI | OpenAI chat completions | Yes | Yes |
RAILGemini | Google Gemini | Yes | Yes |
RAILAnthropic | Anthropic Claude | Yes | Yes |
RAILLangChain | Any LangChain LLM | Yes | — |
| Custom wrapper | Any HTTP-based LLM | Yes | Yes |
Observe mode vs enforce mode
- Observe only
- Enforce threshold
- Auto-regenerate
Score every response, never block. Use this to measure quality without interrupting the response flow.
Writing custom middleware
If you use an LLM provider without a built-in wrapper, build your own middleware using the coreeval() call:
What’s next
Concepts: Policy Engine
Declarative rules to act on scores across a session.
Python: Integrations
Full provider wrapper documentation and options.
JavaScript: Providers
TypeScript wrappers for OpenAI, Gemini, Anthropic.
Python: Middleware SDK
RAILMiddleware - wrap any LLM function.