Quickstart

Use the links below to learn how to define and run a Workflow in Vellum using the Workflows SDK or pull a Workflow from the Vellum UI.

Code-first

The instructions below will guide you through the process of creating a simple Workflow using the Vellum Workflows SDK. If you’re looking for instructions from a UI-first perspective (e.g. pulling an existing Workflow to run & modify locally via code), see the UI-first quickstart.

1

Install the Vellum Workflows SDK:

$pip install vellum-ai
2

Import the Vellum Workflows SDK and define your first Workflow:

1# my_workflow.py
2
3from vellum.workflows import BaseWorkflow
4from vellum.workflows.nodes import BaseNode
5
6
7class MyNode(BaseNode):
8
9 class Outputs(BaseNode.Outputs):
10 result: str
11
12 def run(self):
13 return self.Outputs(result="Hello, World!")
14
15
16class MyWorkflow(BaseWorkflow):
17 graph = MyNode
18
19 class Outputs(BaseWorkflow.Outputs):
20 result = MyNode.Outputs.result
21
22
23if __name__ == "__main__":
24 workflow = MyWorkflow()
25 result = workflow.run()
26
27 print(result.outputs.result)
3

Run it!

$python my_workflow.py
To use most out-of-box Nodes, and to push/pull to/from the Vellum UI, you’ll need a Vellum account and API key. Talk to us or visit our pricing page for more information.

Next Steps

UI-first

The instructions below will guide you through the process of pulling an existing Workflow from the Vellum UI such that you can modify and run it locally using the Vellum Workflows SDK. If you’re looking for instructions from a code-first perspective (e.g. defining a Workflow in code and then running it in the Vellum UI), see the code-first quickstart.

1

Create a new folder for your project, setup and activate a virtual environment

$mkdir my_workflow
>cd my_workflow
>python -m venv venv
>source venv/bin/activate
The Vellum Workflows SDK requires Python 3.9+ which you can download here
2

Create a pyproject.toml file

1[project]
2name = "my_project"
3version = "0.0.1"
4
5[[tool.vellum.workflows]]
6module = "my_workflow"
7workflow_sandbox_id = "<we'll get this from the Vellum UI>"
3

Get a Sandbox ID from the Vellum UI

Go to a Workflow Sandbox in the Vellum UI and copy the ID from the URL. The ID is the last part of the URL:

For a URL like this: https://app.vellum.ai/workflow-sandboxes/28fbaf9c-b89e-4534-87f7-abcdefghijkl

The workflow_sandbox_id is 28fbaf9c-b89e-4534-87f7-abcdefghijkl

Replace the workflow_sandbox_id in your pyproject.toml file with this ID.

4

Set your Vellum API key

You can find this at the bottom of the API Keys page in Vellum. This page can be found in the section of the left sidebar in Vellum, or going directly to https://app.vellum.ai/api-keys. Then, run:

$export VELLUM_API_KEY=<your-api-key>
5

Use the Vellum CLI to pull the Workflow

$vellum pull my_workflow --include-sandbox
6

Run it!

$python -m my_workflow.sandbox

Next Steps

Built with