---
title: "OpenAI-compatible pipeline endpoint"
method: POST
path: "/api/pipelines/{id}/chat/completions"
---

# OpenAI-compatible pipeline endpoint

`POST /api/pipelines/{id}/chat/completions`

## Request

- Base URL: `https://www.trezalabs.com`
- URL: `https://www.trezalabs.com/api/pipelines/{id}/chat/completions`
- Auth: HTTP bearer

Drop-in replacement for the OpenAI chat completions API. Point any OpenAI SDK at this base URL with a Treza API key. The latest user message is fed into the pipeline and the pipeline output is returned as the assistant message. Supports streaming via server-sent events.

## Path parameters

- `id` string, required

## Request body

- object
  - `messages` object[], required
    - `role` string
    - `content` string
  - `stream` boolean

## Response `200`

Chat completion (JSON, or SSE when stream is true)

## Other responses

- `401`: Missing or invalid API key
- `402`: Insufficient prepaid credits. The OpenAI-style error object carries code INSUFFICIENT_CREDITS, balanceUsd, and a topUpUrl to relay to a human.
- `403`: Key does not own this pipeline
- `404`: Pipeline not found
- `409`: Pipeline is not published

---

[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)
