Vellum is coming to the AI Engineering World's Fair in SF. Come visit our booth and get a live demo!

Running Arbitrary Code in Workflows & Evals

Write and execute Python or TypeScript directly in your workflow

3 min
Written by
Reviewed by
No items found.

We know that AI development isn’t a rigid, one-size-fits-all process; it’s highly iterative, with needs that can change from project to project.

This flexibility is especially critical as AI tech evolves and new data sources, orchestration techniques, and business requirements emerge. With Vellum, our goal is to give engineering and product teams the tools to adapt quickly, ensuring that your orchestration setup can grow with your needs.

While our out-of-the-box nodes like RAG, Map node, model connectors, guardrails, error nodes (and 10 other Nodes!) are designed to cover common needs, we recognize that real-world AI applications often demand more. You might need to bring in a unique data feed, build out a specialized evaluation metric, or apply complex, project-specific logic that goes beyond standard integrations.

That’s why we built custom code execution nodes into Vellum’s platform. With these nodes, you can write and execute Python or TypeScript directly in your workflow, extending your build beyond pre-set functions while staying within Vellum’s visual builder.

Here’s a closer look at what makes this feature so versatile.

Arbitrary Code Execution in Workflows

Imagine this: You’re setting up a workflow to give users up-to-date weather info.

Preview of a code execution node that references two packages and API secrets to get weather data

You’ve got the basic workflow configured in Vellum, but you need it to call APIs, like Google Maps for coordinates and OpenWeather for the forecast, then return formatted data to your users. Out of the box, that’s complicated to manage without custom code.

With Vellum’s code execution nodes, you’re now able to write custom code in Python and TypeScript and build and test this functionality in our in-browser IDE.

Here’s what else you can do:

Importing Third-Party Packages

With support for any public package from PyPI and npm, you’re not restricted to standard library functions. Import packages like requests for HTTP requests or googlemaps for location data, and integrate them seamlessly into your workflow.

Securely Referencing Secrets

Vellum provides a secure secret store, allowing you to reference secrets in your code (e.g. API credentials) without inlining their literal values. Find more details on this link on how to set up and use secrets in Vellum.

In-Browser Testing and Debugging

Test your custom logic on the spot.

With Vellum’s in-browser IDE, you can write, test, and debug code within the platform—no need for a separate environment or complex deployment process. Test runs show output logs immediately, so you can troubleshoot quickly and confidently.

Vellum’s code execution also extends to evaluation metrics, where you can write arbitrary code to create custom metrics to evaluate model responses.

Building reusable eval metrics

Let’s say that you want to create an eval metric that measures the percentage difference between two JSON objects by comparing their structure and content. You can use the deepdiff package, a couple of inputs, and this Python code:

from deepdiff import DeepDiff

def get_leaf_nodes(json_obj):
        leaf_nodes = []

        def traverse(obj):
            if isinstance(obj, dict):
                for key, value in obj.items():
                    traverse(value)
            elif isinstance(obj, list):
                for index, item in enumerate(obj):
                    traverse(item)
            else:
                leaf_nodes.append(obj)

        traverse(json_obj)
        return leaf_nodes

def get_num_of_diffs(diff):
    if len(diff) == 0:
        return 0
    else:
        changes = 0
        for item_change in diff:
            changes += len(diff[item_change])
        return changes

def compare_func(x, y, level):
    if (not isinstance(x, dict) or not isinstance(y, dict)):
        raise CannotCompare
    if(level.path() == "root['items_in_receipt']"):
        if (x["name"] == y["name"]):
            return True
        return False

def main(
    actual,
    expected,
    ignore_order=True,
    ignore_case=True
) -> dict:
    """Produces a dict containing at least a "score" key with a numerical value."""
    
    # Convert expected string to JSON object
    actual = json.loads(actual)
    expected = json.loads(expected)

    diff = DeepDiff(actual, expected, ignore_order=ignore_order, ignore_string_case=ignore_case)
    print(diff)

    diffs = get_num_of_diffs(diff)

    nodes_a = get_leaf_nodes(actual)
    nodes_e = get_leaf_nodes(expected)

    longest_json = max(len(nodes_a), len(nodes_e))

    score = (longest_json-diffs)/longest_json * 100
    
    return {
        "score": score,
    }

Once you add all this info, here’s what the Code Execution Node for this metric will look like:

Preview of a JSON metric in a Code Execution Node that measures the difference between two JSON objects

This is ideal for teams focused on ML and AI who need consistent evaluation standards.

Imagine writing dozens of script like these — then centralizing them as “blessed” standards your team can reuse across different workflows, ensuring consistency and saving time.

How to Get Started

To start using Code Execution Nodes in your Workflows, simply select the Node in your Workflow builder, and start defining and testing your arbitrary code:

Preview of the Node selection bar in Vellum Workflows

Start by scripting out the logic, import necessary packages, and reference any secrets securely. Testing is simple, with in-browser testing allowing you to confirm the output in real-time. From there, you’re set to deploy within workflows or evaluations, ensuring smooth, consistent performance. The best place to start is to check our docs on code execution examples.

If you want to define a custom metric using the Code Execution Node, you can follow the tutorial outlined on this link.

Try Vellum Workflows today

With Vellum’s code execution nodes, you gain the freedom to build workflows your way—whether that’s connecting to external APIs, integrating complex business logic, or defining custom evaluation metrics.

If your team wants to try out Vellum’s custom code execution and our visual builder, now’s the perfect time to explore how this flexibility can support your projects. Contact us on this link and we’ll have one of our AI experts help you setup your project.

ABOUT THE AUTHOR
Noa Flaherty
Co-founder & CTO

Noa Flaherty, CTO and co-founder at Vellum (YC W23) is helping developers to develop, deploy and evaluate LLM-powered apps. His diverse background in mechanical and software engineering, as well as marketing and business operations gives him the technical know-how and business acumen needed to bring value to nearly any aspect of startup life. Prior to founding Vellum, Noa completed his undergrad at MIT and worked at three tech startups, including roles in MLOps at DataRobot and Product Engineering at Dover.

ABOUT THE reviewer

No items found.
lAST UPDATED
Nov 13, 2024
share post
Expert verified
Related Posts
Guides
October 21, 2025
15 min
AI transformation playbook
LLM basics
October 20, 2025
8 min
The Top Enterprise AI Automation Platforms (Guide)
LLM basics
October 10, 2025
7 min
The Best AI Workflow Builders for Automating Business Processes
LLM basics
October 7, 2025
8 min
The Complete Guide to No‑Code AI Workflow Automation Tools
All
October 6, 2025
6 min
OpenAI's Agent Builder Explained
Product Updates
October 1, 2025
7
Vellum Product Update | September
The Best AI Tips — Direct To Your Inbox

Latest AI news, tips, and techniques

Specific tips for Your AI use cases

No spam

Oops! Something went wrong while submitting the form.

Each issue is packed with valuable resources, tools, and insights that help us stay ahead in AI development. We've discovered strategies and frameworks that boosted our efficiency by 30%, making it a must-read for anyone in the field.

Marina Trajkovska
Head of Engineering

This is just a great newsletter. The content is so helpful, even when I’m busy I read them.

Jeremy Hicks
Solutions Architect

Experiment, Evaluate, Deploy, Repeat.

AI development doesn’t end once you've defined your system. Learn how Vellum helps you manage the entire AI development lifecycle.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Build AI agents in minutes with Vellum
Build agents that take on the busywork and free up hundreds of hours. No coding needed, just start creating.

General CTA component, Use {{general-cta}}

Build AI agents in minutes with Vellum
Build agents that take on the busywork and free up hundreds of hours. No coding needed, just start creating.

General CTA component  [For enterprise], Use {{general-cta-enterprise}}

The best AI agent platform for enterprises
Production-grade rigor in one platform: prompt builder, agent sandbox, and built-in evals and monitoring so your whole org can go AI native.

[Dynamic] Ebook CTA component using the Ebook CMS filtered by name of ebook.
Use {{ebook-cta}} and add a Ebook reference in the article

Thank you!
Your submission has been received!
Oops! Something went wrong while submitting the form.
Button Text

LLM leaderboard CTA component. Use {{llm-cta}}

Check our LLM leaderboard
Compare all open-source and proprietary model across different tasks like coding, math, reasoning and others.

Case study CTA component (ROI)

40% cost reduction on AI investment
Learn how Drata’s team uses Vellum and moves fast with AI initiatives, without sacrificing accuracy and security.

Case study CTA component (cutting eng overhead) = {{coursemojo-cta}}

6+ months on engineering time saved
Learn how CourseMojo uses Vellum to enable their domain experts to collaborate on AI initiatives, reaching 10x of business growth without expanding the engineering team.

Case study CTA component (Time to value) = {{time-cta}}

100x faster time to deployment for AI agents
See how RelyHealth uses Vellum to deliver hundreds of custom healthcare agents with the speed customers expect and the reliability healthcare demands.

[Dynamic] Guide CTA component using Blog Post CMS, filtering on Guides’ names

100x faster time to deployment for AI agents
See how RelyHealth uses Vellum to deliver hundreds of custom healthcare agents with the speed customers expect and the reliability healthcare demands.
New CTA
Sorts the trigger and email categories

Dynamic template box for healthcare, Use {{healthcare}}

Start with some of these healthcare examples

Healthcare explanations of a patient-doctor match
Summarize why a patient was matched with a specific provider.
Population health insights reporter
Combine healthcare sources and structure data for population health management.

Dynamic template box for insurance, Use {{insurance}}

Start with some of these insurance examples

Insurance claims automation agent
Collect and analyze claim information, assess risk and verify policy details.
AI agent for claims review
Review healthcare claims, detect anomalies and benchmark pricing.
Agent that summarizes lengthy reports (PDF -> Summary)
Summarize all kinds of PDFs into easily digestible summaries.

Dynamic template box for eCommerce, Use {{ecommerce}}

Start with some of these eCommerce examples

E-commerce shopping agent
Check order status, manage shopping carts and process returns.

Dynamic template box for Marketing, Use {{marketing}}

Start with some of these marketing examples

LinkedIn Content Planning Agent
Create a 30-day Linkedin content plan based on your goals and target audience.
Competitor research agent
Scrape relevant case studies from competitors and extract ICP details.

Dynamic template box for Sales, Use {{sales}}

Start with some of these sales examples

Research agent for sales demos
Company research based on Linkedin and public data as a prep for sales demo.

Dynamic template box for Legal, Use {{legal}}

Start with some of these legal examples

PDF Data Extraction to CSV
Extract unstructured data (PDF) into a structured format (CSV).
AI legal research agent
Comprehensive legal research memo based on research question, jurisdiction and date range.

Dynamic template box for Supply Chain/Logistics, Use {{supply}}

Start with some of these supply chain examples

Risk assessment agent for supply chain operations
Comprehensive risk assessment for suppliers based on various data inputs.

Dynamic template box for Edtech, Use {{edtech}}

Start with some of these edtech examples

Turn LinkedIn Posts into Articles and Push to Notion
Convert your best Linkedin posts into long form content.

Dynamic template box for Compliance, Use {{compliance}}

Start with some of these compliance examples

No items found.

Dynamic template box for Customer Support, Use {{customer}}

Start with some of these customer support examples

Q&A RAG Chatbot with Cohere reranking
Trust Center RAG Chatbot
Read from a vector database, and instantly answer questions about your security policies.

Template box, 2 random templates, Use {{templates}}

Start with some of these agents

Clinical trial matchmaker
Match patients to relevant clinical trials based on EHR.
Legal contract review AI agent
Asses legal contracts and check for required classes, asses risk and generate report.

Template box, 6 random templates, Use {{templates-plus}}

Build AI agents in minutes

Turn LinkedIn Posts into Articles and Push to Notion
Convert your best Linkedin posts into long form content.
Q&A RAG Chatbot with Cohere reranking
Trust Center RAG Chatbot
Read from a vector database, and instantly answer questions about your security policies.
Insurance claims automation agent
Collect and analyze claim information, assess risk and verify policy details.
PDF Data Extraction to CSV
Extract unstructured data (PDF) into a structured format (CSV).
Research agent for sales demos
Company research based on Linkedin and public data as a prep for sales demo.

Build AI agents in minutes for

{{industry_name}}

Clinical trial matchmaker
Match patients to relevant clinical trials based on EHR.
Prior authorization navigator
Automate the prior authorization process for medical claims.
Population health insights reporter
Combine healthcare sources and structure data for population health management.
Legal document processing agent
Process long and complex legal documents and generate legal research memorandum.
Legal contract review AI agent
Asses legal contracts and check for required classes, asses risk and generate report.
Legal RAG chatbot
Chatbot that provides answers based on user queries and legal documents.

Case study results overview (usually added at top of case study)

What we did:

1-click

This is some text inside of a div block.

28,000+

Separate vector databases managed per tenant.

100+

Real-world eval tests run before every release.