Skip to main content
POST
/
defend
/
{workflow_id}
/
events
Submit a Workflow Event
from deeprails import DeepRails

DEEPRAILS_API_KEY = "YOUR_API_KEY"

client = DeepRails(
    api_key=DEEPRAILS_API_KEY,
)

event_response = client.defend.submit_event(
    workflow_id="wkfl_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    model_input={
            "user_prompt": "Hello, how are you?",
            "system_prompt": "You are a helpful assistant."
    },
    model_output="I am good, thank you!",
    model_used="gpt-4o-mini",
    run_mode="smart",
    nametag="test",
)
print(event_response)
{
  "event_id": "evt_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "workflow_id": "wkfl_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "created_at": "2025-11-10T01:32:44.591Z",
  "status": "In Progress"
}
Workflow events represent individual LLM calls in your production use case. Whenever you receive a new LLM response, you can submit it, along with the input, to the workflow for evaluation and remediation. The model_input field in the request must be adictionary (containing at least a system_prompt field or a user_prompt field), and the request must also includethe model_used to generate the output (Ex. gpt-5-mini), the selected run_mode that determines speed/accuracy/cost for evaluation, and optionally a nametag for the workflow event.

The run mode determines which models power the evaluation:
- precision_plus - Maximum accuracy using the most advanced models
- precision - High accuracy with optimized performance
- smart - Balanced speed and accuracy (default)
- economy - Fastest evaluation at lowest cost

The event’s evaluations will be run with the guardrail metrics and improvement action configured in its associated workflow.

When you create a workflow event, you’ll receive an event ID. Use this ID to track the event’s progress and retrieve all evaluations and improvement results.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

workflow_id
string
required

Workflow ID associated with this event.

Body

application/json
model_input
object
required

A dictionary of inputs sent to the LLM to generate output. The dictionary must contain at least a user_prompt field or a system_prompt field. For the ground_truth_adherence guardrail metric, ground_truth should be provided.

  • Option 1
  • Option 2
model_output
string
required

Output generated by the LLM to be evaluated.

model_used
string
required

Model ID used to generate the output, like gpt-4o or o3.

run_mode
enum<string>
required

Run mode for the workflow event. The run mode allows the user to optimize for speed, accuracy, and cost by determining which models are used to evaluate the event. Available run modes include precision_plus, precision, smart, and economy. Defaults to smart.

Available options:
precision_plus,
precision,
smart,
economy
nametag
string

An optional, user-defined tag for the event.

Response

Workflow event created successfully

event_id
string
required

A unique workflow event ID.

Example:

"evt_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

workflow_id
string
required

Workflow ID associated with the event.

Example:

"wkfl_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

created_at
string<date-time>
required

The time the event was created in UTC.

Example:

"2025-11-10T01:32:44.591Z"

status
enum<string>
required

Status of the event.

Available options:
In Progress,
Completed
Example:

"In Progress"