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_xxxxxxxxxxxx",
model_input={
"system_prompt": "You are a helpful tutor specializing in AP science classes.",
"user_prompt": "Explain the difference between mitosis and meiosis in one sentence.",
"context": [{"role": "user", "content": "I have an AP Bio exam tomorrow, can you help me study?"}, {"role": "tutor", "content": "Sure, I'll help you study."}]
},
model_output="Mitosis produces two genetically identical diploid cells for growth and tissue repair, whereas meiosis generates four genetically varied haploid gametes for sexual reproduction.",
model_used="gpt-4o-mini",
run_mode="precision",
nametag="test",
)
print(event_response)curl --request POST \
--url https://api.deeprails.com/defend/{workflow_id}/events \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model_input": {
"user_prompt": "<string>",
"system_prompt": "<string>",
"ground_truth": "<string>",
"context": [
{
"role": "user",
"content": "<string>"
}
]
},
"model_output": "<string>",
"model_used": "<string>",
"nametag": "<string>"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model_input: {
user_prompt: '<string>',
system_prompt: '<string>',
ground_truth: '<string>',
context: [{role: 'user', content: '<string>'}]
},
model_output: '<string>',
model_used: '<string>',
nametag: '<string>'
})
};
fetch('https://api.deeprails.com/defend/{workflow_id}/events', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.deeprails.com/defend/{workflow_id}/events",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model_input' => [
'user_prompt' => '<string>',
'system_prompt' => '<string>',
'ground_truth' => '<string>',
'context' => [
[
'role' => 'user',
'content' => '<string>'
]
]
],
'model_output' => '<string>',
'model_used' => '<string>',
'nametag' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.deeprails.com/defend/{workflow_id}/events"
payload := strings.NewReader("{\n \"model_input\": {\n \"user_prompt\": \"<string>\",\n \"system_prompt\": \"<string>\",\n \"ground_truth\": \"<string>\",\n \"context\": [\n {\n \"role\": \"user\",\n \"content\": \"<string>\"\n }\n ]\n },\n \"model_output\": \"<string>\",\n \"model_used\": \"<string>\",\n \"nametag\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.deeprails.com/defend/{workflow_id}/events")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model_input\": {\n \"user_prompt\": \"<string>\",\n \"system_prompt\": \"<string>\",\n \"ground_truth\": \"<string>\",\n \"context\": [\n {\n \"role\": \"user\",\n \"content\": \"<string>\"\n }\n ]\n },\n \"model_output\": \"<string>\",\n \"model_used\": \"<string>\",\n \"nametag\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.deeprails.com/defend/{workflow_id}/events")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model_input\": {\n \"user_prompt\": \"<string>\",\n \"system_prompt\": \"<string>\",\n \"ground_truth\": \"<string>\",\n \"context\": [\n {\n \"role\": \"user\",\n \"content\": \"<string>\"\n }\n ]\n },\n \"model_output\": \"<string>\",\n \"model_used\": \"<string>\",\n \"nametag\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"event_id": "evt_xxxxxxxxxxxx",
"workflow_id": "wkfl_xxxxxxxxxxxx",
"created_at": "2025-11-10T01:32:44.591Z",
"status": "In Progress",
"billing_request_id": "bill_0123456789abcdefabcd"
}Defend
Submit a Workflow Event
Use this endpoint to submit a model input and output pair to a workflow for evaluation
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_xxxxxxxxxxxx",
model_input={
"system_prompt": "You are a helpful tutor specializing in AP science classes.",
"user_prompt": "Explain the difference between mitosis and meiosis in one sentence.",
"context": [{"role": "user", "content": "I have an AP Bio exam tomorrow, can you help me study?"}, {"role": "tutor", "content": "Sure, I'll help you study."}]
},
model_output="Mitosis produces two genetically identical diploid cells for growth and tissue repair, whereas meiosis generates four genetically varied haploid gametes for sexual reproduction.",
model_used="gpt-4o-mini",
run_mode="precision",
nametag="test",
)
print(event_response)curl --request POST \
--url https://api.deeprails.com/defend/{workflow_id}/events \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model_input": {
"user_prompt": "<string>",
"system_prompt": "<string>",
"ground_truth": "<string>",
"context": [
{
"role": "user",
"content": "<string>"
}
]
},
"model_output": "<string>",
"model_used": "<string>",
"nametag": "<string>"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model_input: {
user_prompt: '<string>',
system_prompt: '<string>',
ground_truth: '<string>',
context: [{role: 'user', content: '<string>'}]
},
model_output: '<string>',
model_used: '<string>',
nametag: '<string>'
})
};
fetch('https://api.deeprails.com/defend/{workflow_id}/events', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.deeprails.com/defend/{workflow_id}/events",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model_input' => [
'user_prompt' => '<string>',
'system_prompt' => '<string>',
'ground_truth' => '<string>',
'context' => [
[
'role' => 'user',
'content' => '<string>'
]
]
],
'model_output' => '<string>',
'model_used' => '<string>',
'nametag' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.deeprails.com/defend/{workflow_id}/events"
payload := strings.NewReader("{\n \"model_input\": {\n \"user_prompt\": \"<string>\",\n \"system_prompt\": \"<string>\",\n \"ground_truth\": \"<string>\",\n \"context\": [\n {\n \"role\": \"user\",\n \"content\": \"<string>\"\n }\n ]\n },\n \"model_output\": \"<string>\",\n \"model_used\": \"<string>\",\n \"nametag\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.deeprails.com/defend/{workflow_id}/events")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model_input\": {\n \"user_prompt\": \"<string>\",\n \"system_prompt\": \"<string>\",\n \"ground_truth\": \"<string>\",\n \"context\": [\n {\n \"role\": \"user\",\n \"content\": \"<string>\"\n }\n ]\n },\n \"model_output\": \"<string>\",\n \"model_used\": \"<string>\",\n \"nametag\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.deeprails.com/defend/{workflow_id}/events")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model_input\": {\n \"user_prompt\": \"<string>\",\n \"system_prompt\": \"<string>\",\n \"ground_truth\": \"<string>\",\n \"context\": [\n {\n \"role\": \"user\",\n \"content\": \"<string>\"\n }\n ]\n },\n \"model_output\": \"<string>\",\n \"model_used\": \"<string>\",\n \"nametag\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"event_id": "evt_xxxxxxxxxxxx",
"workflow_id": "wkfl_xxxxxxxxxxxx",
"created_at": "2025-11-10T01:32:44.591Z",
"status": "In Progress",
"billing_request_id": "bill_0123456789abcdefabcd"
}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
The run mode determines which models power the evaluation (fastest to most thorough):
-
-
-
-
-
-
Note:
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.
model_input field in the request must be a dictionary (containing at least a system_prompt field or a user_prompt field), and the request must also include the 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 (fastest to most thorough):
-
super_fast - High-speed lightweight checks-
fast - Balanced speed and accuracy (default)-
precision - Deep multi-model analysis-
precision_codex - Code-optimized deep analysis-
precision_max - Exhaustive multi-pass verification-
precision_max_codex - Ultimate code-aware verificationNote:
super_fast does not support Web Search or File Search capabilities. Requests using this mode on workflows with Web Search or File Search enabled will be rejected.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
Body
application/json
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 (fastest to most thorough): super_fast, fast, precision, precision_codex, precision_max, and precision_max_codex. Defaults to fast. Note: super_fast does not support Web Search or File Search — if your workflow has these capabilities enabled, use a different run mode or edit the workflow to disable them.
Available options:
super_fast, fast, precision, precision_codex, precision_max, precision_max_codex Response
Workflow event created successfully
