---
title: "Create pipeline"
method: POST
path: "/api/v1/tools/create_pipeline"
---

# Create pipeline

`POST /api/v1/tools/create_pipeline`

## Request

- Base URL: `https://www.trezalabs.com`
- URL: `https://www.trezalabs.com/api/v1/tools/create_pipeline`
- Auth: HTTP bearer

Create a new pipeline (as a draft) on your Treza account, from a template (templateId, see list_pipeline_templates) or with an initial node graph. Use list_node_types / get_node_type to learn the graph vocabulary: every edge names the two nodes it joins and a port on each, e.g. {"source":"music","sourceHandle":"audio","target":"sequence","targetHandle":"shots"}. A graph with error-level issues is refused with every issue listed, and nothing is saved. That includes a config key the node does not define, a value outside a field's options or range, and a model id, duration, aspect ratio or voice the chosen model does not offer: pick them from get_node_type. Drafts can be run with run_pipeline; publish_pipeline makes them invokable over the public API. To put music under a video the account already has, call assemble_video with musicPrompt instead of building a graph.

## Request body

- object
  - `name` string, required
  - `description` string
  - `templateId` string: Copy this template's graph (ids from list_pipeline_templates). Ignored when nodes/edges are supplied.
  - `nodes` object[]: The graph's nodes. Pass together with edges.
    - `id` string, required: Unique id. Edges, and run_pipeline inputs, refer to the node by it.
    - `type` string, required: A node type from list_node_types, e.g. "file", "music-gen", "sequence", "output".
    - `label` string: Name shown on the canvas.
    - `position` object: Canvas position. Laid out automatically when omitted.
      - `x` number, required
      - `y` number, required
    - `config` object: Settings, as get_node_type's configSchema describes them. A node this call adds starts from its type's defaults, and what you pass overrides them.
  - `edges` object[]: Wires between node ports, e.g. {"source":"music","sourceHandle":"audio","target":"sequence","targetHandle":"shots"}. Pass together with nodes; [] for none.
    - `id` string: Unique id for this wire. Assigned when omitted.
    - `source` string, required: Id of the node the wire leaves, as given in `nodes`.
    - `sourceHandle` string, required: Output port on the source node: an `outputs` id from get_node_type, e.g. "audio" on music-gen or "video" on sequence. "out" is the generic output the canvas draws; name the port instead on a node with more than one output besides "result" (update_pipeline refuses a new generic wire there).
    - `target` string, required: Id of the node the wire enters, as given in `nodes`.
    - `targetHandle` string, required: Input port on the target node: an `inputs` id from get_node_type, e.g. "shots" on sequence or "prompt" on music-gen. "in" is the generic input the canvas draws, which guesses a port by media type at run time; name the port instead on a node with more than one input (update_pipeline refuses a new generic wire there).

## Response `200`

The tool's result.

- object

## Other responses

- `400`: The arguments were refused. `error` says why.
- `401`: No API key, or one that is not valid.
- `402`: The credit balance does not cover this run.
- `403`: The API key lacks a permission this tool needs.
- `404`: No such tool, or the pipeline, run or asset is not on this account.
- `429`: Too many runs started or in progress. Wait, then try again.

---

[API](https://skmtc.dev/trezalabs/apis/treza-pipelines-api.md) · [All operations](https://skmtc.dev/trezalabs/apis/treza-pipelines-api/llms.txt) · [OpenAPI document](https://skmtc.dev/trezalabs/apis/treza-pipelines-api/revisions/a76574c1731b?raw)
