Pipeline API
Every published pipeline is a versioned HTTP endpoint. There are two ways to call it: the typed /invoke endpoint for JSON in and JSON out, and an OpenAI-compatible /chat/completions endpoint that works as a drop-in for any OpenAI SDK, streaming included.
Base URL
https://trezalabs.comBoth endpoints live under /api/pipelines/<id>, where <id> is the pipeline's id from the dashboard. They accept and return application/json (the streaming variant returns Server-Sent Events).
Authentication
Authenticate with a Treza API key, created on the API keys page in the dashboard and sent as a bearer token:
Authorization: Bearer treza_live_...The key (treza_live_...) is shown once at creation. Store it in a secrets manager. A key can only invoke pipelines owned by the same account, and the pipeline must be published.
Prerequisites
For a pipeline to accept API calls it must be published and have at least one input node and one output node. The input keys you send and the output keys you receive are derived from those nodes (the pipeline's contract). See Publishing & versioning.
POST /api/pipelines/{id}/invoke
POST /api/pipelines/{id}/invokeStarts a run of the published pipeline with typed inputs. Runs execute asynchronously on Treza's background workers, so this returns a runId immediately โ poll GET .../invoke for the result.
Request
inputs
object
Map of the pipeline's input keys to values. Keys come from your input nodes.
Response 202 Accepted
202 AcceptedrunId
Id of the run to poll. Also appears in run history.
status
Always running on accept.
version
The published version serving the run.
statusUrl
Ready-made URL to poll for status and outputs.
GET /api/pipelines/{id}/invoke
GET /api/pipelines/{id}/invokePolls a run started by POST .../invoke. Same bearer API key.
Request
runId
The runId returned by POST .../invoke (URL-encode it).
Response
While the run is in progress:
Once finished:
status
running, success, error, or partial.
outputs
Map keyed by your output nodes' keys (present once finished).
usage
Token counts and provider cost (costUsd) for the run.
durationMs
Wall-clock run time in milliseconds (once finished).
Poll statusUrl every few seconds until status is no longer running. Video and image generation poll asynchronous provider jobs, so a run can take a while. Output media URLs are returned verbatim; long text outputs are truncated in the polled result.
POST /api/pipelines/{id}/chat/completions
POST /api/pipelines/{id}/chat/completionsAn OpenAI-compatible chat-completions endpoint. Point any OpenAI SDK at it by changing the base URL and API key. The latest user message is fed into the pipeline's entry node, and the output node's value is returned as the assistant message.
curl
The model field is accepted but not used to pick a model (the pipeline's nodes decide that); send any string.
Python (OpenAI SDK)
TypeScript (OpenAI SDK)
Response
A standard OpenAI chat-completion object:
Two response headers help you tie a completion back to a run:
x-treza-run-id
Id of the recorded run.
x-treza-pipeline-version
The published version that served the request.
Streaming
Set "stream": true to receive the response as Server-Sent Events, emitted as chat.completion.chunk objects and terminated by data: [DONE]. The final chunk carries finish_reason: "stop" and a usage block. Any OpenAI SDK's streaming mode works unchanged.
Errors
Both endpoints share the same authorization and status model. /invoke returns { "error": "..." }; /chat/completions returns OpenAI-style { "error": { "message": ..., "type": ... } }.
400
Malformed request (for example, missing messages on /chat/completions).
401
Missing or invalid API key.
402
Insufficient credits. Top up in billing settings.
403
The key does not own this pipeline.
404
Pipeline not found.
409
Pipeline is not published.
422
The pipeline has no entry node or no output node to serve chat completions.
502
The pipeline ran but a node failed. The failing node's error is included.
500
Internal server error.
Related
Build your first pipeline - end-to-end from the canvas.
Publishing & versioning - versions, rollback, and run history.
REST API - the rest of the Treza Platform API (keys, enclaves, gateway, and more).
Last updated