UI-first Approach

The instructions below will guide you through pulling a Workflow from the Vellum UI to modify and run locally.

1

Set up your environment

Before proceeding, make sure you have set your VELLUM_API_KEY environment variable. See the installation guide for instructions on how to set this up.

2

Get CLI command from Vellum UI

  1. Open a Workflow on the Workflows page in Vellum. In this example we’ll use one of the prebuilt workflows: Prompt Chaining.
Prompt Chain Workflow UI (condensed node view)
  1. Click the “Command Line” option and copy the CLI snippet in the subsequent modal.

    The command should look like this:

    vellum workflows pull --workflow-sandbox-id=<some_id> --include-sandbox

  2. Paste that command into your terminal and voila! You’ve now pulled your Workflow into locally runnable SDK code.

3

Closing out

If you run ls in your terminal, you should see two new items in your current directory:

  • vellum.lock.json
  • prompt_chaining/ (or [your_workflow_module]/)

From here, you can do the following:

Open [your_workflow_module]/workflow.py to see the top-level graph definition for your Workflow. In the Prompt Chaining example, it should look like this:

1# ... node imports ...
2
3class Workflow(BaseWorkflow[Inputs, BaseState]):
4 graph = TopicResearch >> OutlineCreation >> ContentGeneration >> FinalOutput
5 unused_graphs = {Note}
6
7 class Outputs(BaseWorkflow.Outputs):
8 final_output = FinalOutput.Outputs.value

Run the code locally with:

python -m [your_workflow_module].sandbox

To push changes back to the UI, head back to the Workflow Sandbox UI and grab the “push” CLI command from the Command Line UI.

The command should look like this:

vellum workflows push [your_workflow_module]

for example:

vellum workflows push prompt_chaining

Next Steps