For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
BlogLog InRequest Demo
HomeProductDevelopersSelf-HostingChangelog
HomeProductDevelopersSelf-HostingChangelog
  • Getting Started
    • Overview
  • Workflows SDK
    • Introduction
    • Installation
    • Core Concepts
    • Defining Control Flow
    • Configuration
    • Custom Docker Images
      • Displayable Nodes
        • Agent Node
        • Inline Prompt Node
        • Inline Subworkflow Node
        • Prompt Deployment Node
        • Search Node
        • Subworkflow Deployment Node
        • API Node
        • Code Execution Node
        • Templating Node
        • Guardrail Node
        • Map Node
        • Conditional Node
        • Merge Node
        • Error Node
        • Final Output Node
      • Datasets
      • CLI
  • Client SDK
    • Introduction
    • Authentication
    • API Versioning
LogoLogo
BlogLog InRequest Demo
Workflows SDKAPI ReferenceDisplayable Nodes

Guardrail Node

Example Usage
1from vellum import ChatMessage
2from vellum.workflows.nodes import GuardrailNode
3
4class QualityCheckNode(GuardrailNode):
5 release_tag = "production"
6 metric_definition = "response_quality_metric" # or UUID("...")
7 # `metric_inputs` align with the custom Metric we've created in the Vellum UI
8 metric_inputs = {
9 "response": "This is the AI response to evaluate",
10 "chat_history": [
11 ChatMessage(role="USER", text="What's the weather?"),
12 ChatMessage(role="ASSISTANT", text="It's sunny today!")
13 ],
14 "evaluation_criteria": {
15 "coherence": True,
16 "relevance": True,
17 "safety": True
18 }
19 }
Basic Output Example
1QualityCheckNode.Outputs(
2 # `score` is a mandatory field for all Metrics and thus will be available on all Guardrail Nodes
3 score=0.92,
4 # `details` is a result of our custom Metric definition
5 details={
6 "coherence_score": 0.95,
7 "relevance_score": 0.88,
8 "safety_score": 0.93
9 }
10)
Was this page helpful?
Previous

Map Node

Next
Built with

vellum.workflows.nodes.GuardrailNode

Used to execute a Metric Definition and surface a float output representing the score. This node is commonly used to implement quality checks and guardrails in your workflows.

Metrics are defined in the Vellum UI and can be reused across workflows.

Attributes

metric_definition
Union[UUID, str]Required

Either the Metric Definition’s UUID or its name

metric_inputs
EntityInputsInterfaceRequired

The inputs for the Metric

release_tag
strDefaults to LATEST

The release tag to use for the Metric

request_options
Optional[RequestOptions]

The request options to use for the Metric execution

Outputs

score
float

The score output from the metric execution (between 0 and 1)

Additional outputs may be available depending on the metric definition.