Skip to main content

Create an API Key

  1. In your organization’s DeepRails API Console, go to API Keys.
  2. Click Create key, name it, then copy the key.
  3. (Optional) Save it as the DEEPRAILS_API_KEY environment variable.
API Keys – placeholder

Create and manage API keys in the API Console.

Install the SDK

Create your first Defend workflow

Before you can submit events to be evaluated and potentially remediated, you have to create and configure a workflow.

A workflow is an abstraction for a specific production use of Gen AI, and its configurations determine which guardrail metrics are evaluated, at what thresholds, and how issues are remediated.

Types of Workflows

Workflows can either have custom or automatic thresholds, set by the threshold_type. Automatic workflows have adaptive thresholds that change as events are recorded, starting at low, medium, or high values in an automatic_hallucination_tolerance_levels dictionary. Custom workflows have static, fully customizable thresholds for each selected metric set as floating point values in a custom_hallucination_threshold_values dictionary.

Note that workflows set to automatic must have automatic_hallucination_tolerance_levels specified and custom_hallucination_threshold_values is not needed, and vice versa for those set to custom.

Required Parameters

Optional Parameters

Submit a Workflow Event

Use the SDK to log a production event (input + output). This creates a workflow event and automatically triggers an associated evaluation using the guardrail metrics you pass.

If the evaluation fails for one or more metrics, the improvement action specified for the affiliated workflow will be used to remediate the output. Then, that improved output will be evaluated and potentially improved again, if needed.

The improvement process will repeat for that event until all guardrails pass or the maximum number of retries is reached.
Tip: You can also submit a workflow event via the DeepRails API Playground.

Required Parameters

model_input Fields

FieldTypeRequiredDescription
user_promptstringYesThe user prompt sent to the LLM.
system_promptstringNoThe system prompt used to configure the LLM’s behavior.
ground_truthstringNoThe expected correct answer. Required when the workflow evaluates the ground_truth_adherence metric.
contextarrayNoStructured context for the evaluation, such as conversation history or domain-specific facts. Each item should have role and content fields. Required when context_awareness is enabled on the workflow.

Optional Parameters

Retrieve Workflow and Event Details

You can retrieve workflow details and fetch events from a specific workflow. Events are processed asynchronously, so you will need to poll using the event ID until the status is Completed.

Check Defend Outcomes via the API Console

  1. Open DeepRails API Console → Defend → Data.
  2. Filter by time range or search by workflow_id or nametag to find events.
  3. Open any event to see guardrail scores and remediation chains (FixIt/ReGen).
Defend data – placeholder

Browse real-time Defend events, filters, and remediation details in the Defend API Control Panel.

Next Steps

Configure Guardrails

Explore the metrics behind evaluations—correctness, safety, completeness, and more.

Defend Overview

Learn how workflows, metrics, and remediation work together.