Workflows

AI workflow API. A JSON graph of model calls, run with one request.

Name the inputs, list the nodes, template each prompt from the inputs and earlier outputs. Run it, poll it, read every step and its charge. Write the graph here or in the console.

The graph

Each node is one model call. A {{nodes.x.output}} reference makes a node wait for another; nodes with no dependency between them run at the same time.

json
1{
2 "inputs": ["article"],
3 "nodes": [
4 {
5 "id": "summary",
6 "model": "claude-haiku-5-5",
7 "prompt": "Summarize in three sentences:\n\n{{inputs.article}}",
8 "max_tokens": 300
9 },
10 {
11 "id": "title",
12 "model": "claude-sonnet-5-5",
13 "system": "You write headlines.",
14 "prompt": "Write one headline for this summary:\n\n{{nodes.summary.output}}",
15 "max_tokens": 40
16 },
17 {
18 "id": "spanish",
19 "model": "gpt-5.5",
20 "prompt": "Translate to Spanish:\n\n{{nodes.summary.output}}",
21 "if": "{{inputs.article}}"
22 }
23 ],
24 "outputs": {
25 "headline": "{{nodes.title.output}}",
26 "summary": "{{nodes.summary.output}}",
27 "summary_es": "{{nodes.spanish.output}}"
28 }
29}
As the console draws the run
  1. summaryclaude-haiku-5-5
    first · max_tokens 300
  2. titleclaude-sonnet-5-5
    after summary · max_tokens 40
  3. spanishgpt-5.5
    after summary · conditional

Each node: a normal request to its model, at the per-token price on the model page.

Each run: the steps summed, plus $0.005. No monthly fee.

A failed run: only the steps that completed bill. The run answers with the error and the steps it got through.

Create, run, poll

bash
1curl https://api.relayswitch.io/v1/workflows \
2 -H "Authorization: Bearer $RELAYSWITCH_KEY" \
3 -H "Content-Type: application/json" \
4 -d '{ "name": "summarize-and-title", "graph": '"$(cat graph.json)"' }'
bash
1curl https://api.relayswitch.io/v1/workflows/WORKFLOW_ID/runs \
2 -H "Authorization: Bearer $RELAYSWITCH_KEY" \
3 -H "Content-Type: application/json" \
4 -d '{ "key_id": "KEY_ID", "inputs": { "article": "..." } }'
bash
1curl https://api.relayswitch.io/v1/workflows/WORKFLOW_ID/runs/RUN_ID \
2 -H "Authorization: Bearer $RELAYSWITCH_KEY"

The run call answers 202 with run_id. The poll answers with status, steps (each with its status and charge_usd), outputs and the total. The console's Workflows page runs the same graph from a form and lists every run.

FAQs

Questions

Graphs, billing, branching.

Open the console

A key in under a minute

Get a key

Or email hello@relayswitch.io

Write the graph, run it from the console

One request, every step priced, no monthly fee.