GuardrailRules
List GuardrailRules
Returns a paginated list of guardrail rules for the current project.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.guardrail_rules.list(limit=10)
# Handle response
print(res)
Show Parameters
Show Parameters
{
"limit": Optional[int],
"starting_after": Optional[str],
"ending_before": Optional[str],
"project_id": Optional[str],
}
Show Response
Show Response
{
"data": {
"id": str,
"created_at": date,
"created_by_id": str,
"description": Optional[str],
"display_name": str,
"enabled": bool,
"expression": { # optional
"cel": str,
"config": Dict[str, Any],
},
"guardrails": { # optional
"execute_on": Literal["input", "output", "both"],
"id": str,
"is_guardrail": Optional[bool],
"sample_rate": Optional[float],
},
"project_id": str,
"timeout": int,
"updated_at": date,
"updated_by_id": str,
},
"has_more": bool,
"object": str,
}
Create a GuardrailRule
Creates a new guardrail rule with expression, guardrails configuration, and timeout settings.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.guardrail_rules.create(display_name="Rosemarie_Wisoky")
# Handle response
print(res)
Show Parameters
Show Parameters
{
"display_name": str, # required
"description": Optional[str],
"enabled": Optional[bool],
"expression": { # optional
"cel": str, # required
},
"guardrails": { # optional
"execute_on": Literal["input", "output", "both"], # required
"id": str, # required
"is_guardrail": Optional[bool],
"sample_rate": Optional[float],
},
"project_id": Optional[str],
"timeout": Optional[int],
}
Show Response
Show Response
{
"id": str,
"created_at": date,
"created_by_id": str,
"description": Optional[str],
"display_name": str,
"enabled": bool,
"expression": { # optional
"cel": str,
"config": Dict[str, Any],
},
"guardrails": { # optional
"execute_on": Literal["input", "output", "both"],
"id": str,
"is_guardrail": Optional[bool],
"sample_rate": Optional[float],
},
"project_id": str,
"timeout": int,
"updated_at": date,
"updated_by_id": str,
}
Delete a GuardrailRule
Deletes an existing guardrail rule by ID.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
orq.guardrail_rules.delete(guardrail_rule_id="<id>")
# Use the SDK ...
Show Parameters
Show Parameters
{
"guardrail_rule_id": str, # required
}
Retrieve a GuardrailRule
Retrieves the details of an existing guardrail rule by ID.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.guardrail_rules.retrieve(guardrail_rule_id="<id>")
# Handle response
print(res)
Show Parameters
Show Parameters
{
"guardrail_rule_id": str, # required
}
Show Response
Show Response
{
"id": str,
"created_at": date,
"created_by_id": str,
"description": Optional[str],
"display_name": str,
"enabled": bool,
"expression": { # optional
"cel": str,
"config": Dict[str, Any],
},
"guardrails": { # optional
"execute_on": Literal["input", "output", "both"],
"id": str,
"is_guardrail": Optional[bool],
"sample_rate": Optional[float],
},
"project_id": str,
"timeout": int,
"updated_at": date,
"updated_by_id": str,
}
Update a GuardrailRule
Partially updates an existing guardrail rule. Only provided fields are updated.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.guardrail_rules.update(guardrail_rule_id="<id>")
# Handle response
print(res)
Show Parameters
Show Parameters
{
"guardrail_rule_id": str, # required
"description": Optional[str],
"display_name": Optional[str],
"enabled": Optional[bool],
"expression": { # optional
"cel": str, # required
},
"guardrails": { # optional
"execute_on": Literal["input", "output", "both"], # required
"id": str, # required
"is_guardrail": Optional[bool],
"sample_rate": Optional[float],
},
"timeout": Optional[int],
}
Show Response
Show Response
{
"id": str,
"created_at": date,
"created_by_id": str,
"description": Optional[str],
"display_name": str,
"enabled": bool,
"expression": { # optional
"cel": str,
"config": Dict[str, Any],
},
"guardrails": { # optional
"execute_on": Literal["input", "output", "both"],
"id": str,
"is_guardrail": Optional[bool],
"sample_rate": Optional[float],
},
"project_id": str,
"timeout": int,
"updated_at": date,
"updated_by_id": str,
}