> For the complete documentation index, see [llms.txt](https://docs.trezalabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.trezalabs.com/api/tools-api.md). Agents can also search and read this documentation through its [MCP server](https://docs.trezalabs.com/~gitbook/mcp).

# Tools API

Every tool on the [MCP server](https://docs.trezalabs.com/api/mcp-server.md) is also a plain HTTP endpoint: `POST /api/v1/tools/<name>`, with the tool's arguments as a JSON body and its result as the JSON response. It is what the Treza apps for Zapier, n8n and Make call, and it suits any client that wants an HTTP API rather than MCP: a workflow tool, a backend job, a `curl` script.

The tools, their arguments, their answers and their refusals are the MCP server's, word for word: every tool an API key can call over MCP is here, and a tool added to the MCP server is on this API at once. The tools only Treza's chat panels call (`confirm_publish`, `open_library`, `quote_status`) are not, and neither is `create_api_key`, which an API key never gets.

{% hint style="info" %}
To call one **published pipeline** with typed inputs, the [Pipeline API](https://docs.trezalabs.com/api/pipeline-api.md) is simpler. This API covers everything else too: making a video or a picture from a prompt, running any pipeline, the asset library, assembling and editing videos, and reading runs.
{% endhint %}

***

## Base URL

```
https://www.trezalabs.com/api/v1
```

| Endpoint             | Auth    | What it returns                                                                                                                                                                                               |
| -------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `GET /tools`         | none    | Every tool with its title, description and JSON Schema for its arguments                                                                                                                                      |
| `POST /tools/{name}` | API key | The tool's result                                                                                                                                                                                             |
| `GET /openapi.json`  | none    | An OpenAPI 3.0 document with every tool as an operation, after the [Pipeline API](https://docs.trezalabs.com/api/pipeline-api.md) and x402 endpoints. Also served at `https://www.trezalabs.com/openapi.json` |

Requests and responses are `application/json`. Tool calls (`POST /tools/{name}`) carry `Cache-Control: no-store`.

***

## Authentication

Send a Treza API key as a bearer token:

```
Authorization: Bearer treza_live_...
```

Keys are made on the **API keys** page in the dashboard (see [API Keys](https://docs.trezalabs.com/api/api-keys.md)). A key reaches only its own account's pipelines, runs and files.

Every tool needs the `pipelines:read` scope; a key granted `pipelines:write` counts as having it. Some need more:

| Scope                                   | Tools                                                                                                                                                                                                                                                                                                |
| --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `pipelines:read` only                   | `list_pipelines`, `get_pipeline`, `list_runs`, `get_run`, `estimate_run_cost`, `get_credit_balance`, `get_profile`, `list_assets`, `list_node_types`, `get_node_type`, `list_pipeline_templates`, `list_projects`, `get_project`, `get_project_render`, `list_connected_channels`, `connect_channel` |
| `+ pipelines:run`                       | `run_pipeline`, `cancel_run`, `render_project`, `get_transcript`                                                                                                                                                                                                                                     |
| `+ pipelines:write`                     | `make_video`, `make_image`, `import_media`, `create_upload_url`, `create_pipeline`, `update_pipeline`, `publish_pipeline`, `set_schedule_paused`, `delete_pipelines`, `publish_asset`, `create_editor_project`, `open_run_in_timeline`, `edit_project`, `undo_project_edit`                          |
| `+ pipelines:run` and `pipelines:write` | `assemble_video`, `edit_asset`, `copy_reference_style`                                                                                                                                                                                                                                               |

An `edit_project` call with a `transcribe` action also needs `pipelines:run`, since re-captioning is charged. A key for an automation that makes and runs renders needs all three.

***

## List the tools

```bash
curl https://www.trezalabs.com/api/v1/tools
```

```json
{
  "call": "POST https://www.trezalabs.com/api/v1/tools/<name> with \"Authorization: Bearer treza_live_...\" and the tool's arguments as a JSON object.",
  "openapi": "https://www.trezalabs.com/api/v1/openapi.json",
  "mcp": "https://www.trezalabs.com/api/mcp",
  "tools": [
    {
      "name": "list_runs",
      "title": "List runs",
      "description": "...",
      "inputSchema": {
        "type": "object",
        "properties": {
          "pipelineId": { "type": "string", "minLength": 1 },
          "limit": { "type": "integer", "minimum": 1, "maximum": 50 }
        },
        "required": ["pipelineId"]
      },
      "annotations": { "readOnlyHint": true }
    }
  ]
}
```

Each tool's `description` explains its arguments and what it returns. `inputSchema` is the exact contract: a call whose arguments don't match it is refused with `400` before anything runs.

***

## Call a tool

```bash
curl https://www.trezalabs.com/api/v1/tools/get_credit_balance \
  -X POST \
  -H "Authorization: Bearer treza_live_..." \
  -H "Content-Type: application/json" \
  -d '{}'
```

The body is the tool's arguments as one JSON object (`{}` or an empty body when it takes none), at most 2 MB. A successful call returns `200` with the tool's result as JSON.

A call answers within 300 seconds. Renders run in the background, so the tools that start one (`run_pipeline`, `assemble_video`, `edit_asset`) return a `runId` at once. Read the run with `get_run` until its `status` is no longer `running`, or give the starting call a `callbackUrl` and Treza POSTs the finished run to it once, when it ends. `render_project` returns a `jobId` instead, which `get_project_render` reports on.

***

## Paid renders

Renders draw from the account's prepaid credit balance, and every paid render is priced before it starts:

1. **Quote.** `make_video` and `make_image` prepare a render from a prompt and answer with its price; for a pipeline, call `estimate_run_cost` with the `inputs` the run will get. The answer has `estimatedChargeUsd`, `sufficient` (whether the balance covers it) and a `quoteId`. Nothing is charged yet. `make_video` and `make_image` also take `maxPriceUsd` and refuse a render that costs more, with `code: "OVER_BUDGET"`.
2. **Start.** `run_pipeline` with the `pipelineId` and `quoteId`. The run starts only at the quoted price and only once: the same call again returns the run already started, so a retry never charges twice. A quote lasts 24 hours. Without a quote, pass a `requestId` of your own for the same protection.
3. **Read.** `get_run` with the `pipelineId` and `runId`. A finished run has its files in `outputs` (a picture from `make_image` is `outputs.image`).

Every account gets a few free images a day on an inexpensive model such as the default, Nano Banana. `make_image` quotes one of them at `estimatedChargeUsd: 0` with `sufficient: true`, `freeImage: true` and `freeImagesLeftToday`, with the usual price in `listChargeUsd`, and `maxPriceUsd` does not rule it out. If the day's free images are used up before `run_pipeline` is called, the run is refused with `PRICE_CHANGED` and the real price rather than charged.

### Example: one picture

This one is priced once the day's free images are used.

```bash
# 1. Quote it
curl https://www.trezalabs.com/api/v1/tools/make_image -X POST \
  -H "Authorization: Bearer treza_live_..." -H "Content-Type: application/json" \
  -d '{ "prompt": "A red fox in fresh snow at dawn", "aspectRatio": "1:1", "maxPriceUsd": 0.25 }'
```

```json
{
  "pipelineId": "<pipelineId>",
  "quoteId": "<quoteId>",
  "quoteExpiresAt": "2026-11-14T09:30:00.000Z",
  "estimatedChargeUsd": 0.06,
  "sufficient": true,
  "balanceUsd": 20.76,
  "model": { "id": "google/gemini-2.5-flash-image", "name": "Nano Banana (Gemini 2.5 Flash Image)" },
  "aspectRatio": "1:1"
}
```

```bash
# 2. Start it at that price
curl https://www.trezalabs.com/api/v1/tools/run_pipeline -X POST \
  -H "Authorization: Bearer treza_live_..." -H "Content-Type: application/json" \
  -d '{ "pipelineId": "<pipelineId>", "quoteId": "<quoteId>" }'

# 3. Read the run until it finishes
curl https://www.trezalabs.com/api/v1/tools/get_run -X POST \
  -H "Authorization: Bearer treza_live_..." -H "Content-Type: application/json" \
  -d '{ "pipelineId": "<pipelineId>", "runId": "<runId from step 2>" }'
```

The responses are trimmed here; the full ones carry a few more fields (the price broken down by step, a note on what to do next).

***

## Errors

A refused call returns a JSON body with a plain-language `error` sentence, and a `code` where a client might branch on it. Nothing is charged for a refused call.

```json
{
  "error": "This run generates media estimated at ~$1.06 in credits and your balance is $0.40. Add $0.66 in credits to run it.",
  "code": "INSUFFICIENT_CREDITS",
  "balanceUsd": 0.4,
  "topUpUrl": "https://www.trezalabs.com/platform/settings#billing"
}
```

| Status | When                                                                                                                                                               | `code`                                                                                     |
| ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ |
| `400`  | The body isn't a JSON object                                                                                                                                       | `INVALID_BODY`                                                                             |
| `400`  | The arguments don't match the tool's `inputSchema`; the `error` names the argument                                                                                 | `INVALID_REQUEST`                                                                          |
| `400`  | The tool refused the call: over `maxPriceUsd`, an unknown or expired quote, a pipeline changed since its quote, a price that rose since the quote, a missing input | the tool's own, for example `OVER_BUDGET`, `UNKNOWN_QUOTE`, `STALE_QUOTE`, `PRICE_CHANGED` |
| `401`  | No API key, or one Treza doesn't accept                                                                                                                            | `UNAUTHORIZED`                                                                             |
| `402`  | The balance doesn't cover the render; `topUpUrl` is where credits are added                                                                                        | `INSUFFICIENT_CREDITS`                                                                     |
| `403`  | The key lacks `pipelines:read`, or another scope the tool needs, which the `error` names                                                                           | `MISSING_SCOPE`, or `INSUFFICIENT_SCOPE`                                                   |
| `404`  | No tool by that name (the body lists the ones there are), or a pipeline, run, timeline project or render that isn't there or isn't this key's                      | `UNKNOWN_TOOL`, or none                                                                    |
| `413`  | The body is over 2 MB                                                                                                                                              | `BODY_TOO_LARGE`                                                                           |
| `429`  | More than 20 runs started in a minute, or 5 already in progress on the pipeline; try again shortly                                                                 | none                                                                                       |
| `502`  | The tool gave no answer                                                                                                                                            | `NO_RESULT`                                                                                |
| `500`  | Something failed on Treza's side                                                                                                                                   | none                                                                                       |

***

## Tools

`GET /tools` is the full, current list. The ones most integrations use:

| Tool                 | What it does                                                                                |
| -------------------- | ------------------------------------------------------------------------------------------- |
| `get_profile`        | The account the key belongs to (its email). Good for checking a key.                        |
| `get_credit_balance` | The credit balance and where to add credits.                                                |
| `list_pipelines`     | Every pipeline on the account.                                                              |
| `get_pipeline`       | One pipeline, with its input steps (`entryNodes`) that `run_pipeline` takes as `inputs`.    |
| `estimate_run_cost`  | The price of one run of a pipeline, with a `quoteId`.                                       |
| `run_pipeline`       | Starts a run in the background and returns its `runId`.                                     |
| `get_run`            | A run's status, progress and, once finished, its files in `outputs`.                        |
| `list_runs`          | A pipeline's most recent runs (up to 50).                                                   |
| `cancel_run`         | Stops a run that is still going.                                                            |
| `make_video`         | Prepares and prices one video clip from a prompt; `run_pipeline` starts it.                 |
| `make_image`         | Prepares and prices one picture from a prompt, optionally from reference pictures.          |
| `assemble_video`     | Joins clips and pictures into one video, with music, narration, captions and transitions.   |
| `edit_asset`         | Trims, captions, overlays or otherwise edits a video, picture or audio file in the library. |
| `import_media`       | Adds a picture, video or audio file from a public URL to the library.                       |
| `list_assets`        | Files in the library.                                                                       |
| `get_node_type`      | One step type, including the live model list and prices for model steps.                    |

`publish_asset` only lays a post out for review in a chat panel, and posting it takes a press of **Post** there, so over this API post with a pipeline that ends in a `youtube-upload` or `tiktok-upload` step instead.
