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.
The graph
{
"inputs": ["article"],
"nodes": [
{
"id": "summary",
"model": "claude-haiku-5-5",
"prompt": "Summarize in three sentences:\n\n{{inputs.article}}",
"max_tokens": 300
},
{
"id": "title",
"model": "claude-sonnet-5-5",
"system": "You write headlines.",
"prompt": "Write one headline for this summary:\n\n{{nodes.summary.output}}",
"max_tokens": 40
},
{
"id": "spanish",
"model": "gpt-6-1-sol",
"prompt": "Translate to Spanish:\n\n{{nodes.summary.output}}",
"if": "{{inputs.article}}"
}
],
"outputs": {
"headline": "{{nodes.title.output}}",
"summary": "{{nodes.summary.output}}",
"summary_es": "{{nodes.spanish.output}}"
}
}inputsnames what a run takes.{{inputs.article}}puts it in a prompt.- Each node is one model call:
id,model,prompt, an optionalsystem,max_tokensandif.{{nodes.summary.output}}makes a node wait for another. outputsis what the run returns, assembled from the same templates. Nodes with no dependency between them run at the same time.
How a run bills
Each step
A normal request to its model, at the per-token price on the model page.
Per run
The steps summed, plus $0.005. No monthly fee.
On failure
Only the steps that completed bill. The run answers with the error and the steps it got through.
Create, run, poll
curl https://api.uplinkswitch.com/v1/workflows \
-H "Authorization: Bearer $UPLINK_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "name": "summarize-and-title", "graph": '"$(cat graph.json)"' }'curl https://api.uplinkswitch.com/v1/workflows/WORKFLOW_ID/runs \
-H "Authorization: Bearer $UPLINK_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "key_id": "KEY_ID", "inputs": { "article": "..." } }'curl https://api.uplinkswitch.com/v1/workflows/WORKFLOW_ID/runs/RUN_ID \
-H "Authorization: Bearer $UPLINK_API_KEY"The run call answers 202 with run_id. The poll answers with status, steps (each with its status and charge_usd), outputs, charge_usd and fee_usd.
An n8n alternative for model chains
Visual automation tools are built for wiring many services together, and the model call is one node among hundreds. When the whole job is model calls, the editor, the server and the per-execution plan are overhead. A workflow here is the JSON above, versioned with your code, run by one request, with one charge that lists every step.
- No server to host and no execution plan; a run bills what its steps cost.
- Any catalog model in any node, so each step can use the cheapest model that does it.
- Need a tool call in the middle? An agent with a webhook skill does that; a workflow is for the model-only chain.
Questions
- What is an AI workflow API?
- One request that runs several model calls in order. You describe the chain as a JSON graph: named inputs, nodes that each call a model with a templated prompt, and outputs assembled from the node results. The run walks the graph, calls each node and returns every step with its output and its charge.
- How does a run bill?
- Each node bills as a normal request to its model, at that model's per-token price. The run's charge is the sum of those steps plus $0.005. A failed run bills only the steps that completed. There is no monthly fee for workflows.
- Can nodes branch?
- A node with an if template runs only when the template renders to a non-empty string; its output is empty otherwise. Nodes that reference each other run in dependency order, and nodes that do not depend on each other run side by side. Loops are not allowed.
- Is this an n8n alternative?
- For the model-chain part, yes. n8n and similar tools draw a graph of hundreds of integrations in a visual editor and run it on their server or yours. A workflow here is only model calls, written as JSON and run on the gateway, with one bill for the whole chain. If the job is "call these models in this order", it is the shorter path; if it needs a CRM step in the middle, give the agent a skill instead.
- Which models can a node use?
- Any chat model in the catalog, by id, and different nodes can use different models. A cheap model for the bulk step and a stronger one for the final pass is the common shape.
- How do I read the result?
- The run call answers 202 with a run id. GET the run until status is done or error; the answer carries the outputs, each step with its status and charge, and the total. A key_id names which of your keys the run bills to.
Write the graph, run it from the console.
Create a workflow