---
title: "Pipeline"
sidebar_label: "Pipeline"
description: "Kotlin binding reference: Pipeline."
---

<!-- Generated by tools/api_reference/generate_api_docs.py. Do not edit. -->

//[clika-runtime](../../../index.md)/[io.clika.runtime](../index.md)/[Pipeline](index.md)

# Pipeline

[common]\
class [Pipeline](index.md)

A multi-step serving ensemble: each step runs a model under its own executor tuning, wired by name maps into one request/response surface declared by the external schema. [enqueue](enqueue.md) validates the request against that schema and answers at once, with or without callbacks; [await](await.md) blocks for the session's response; [cancel](cancel.md) stops a session at its next step boundary (its completion reads `CANCELLED`); [shutdown](shutdown.md) drains and a later [enqueue](enqueue.md) fails with `FAILED_PRECONDITION`. `AutoCloseable`: [close](close.md) shuts down and releases the pipeline, and the models stay the caller's.

```kotlin
Pipeline.create(listOf(PipelineStep("node", model, inputMap = listOf("x" to "x"), outputMap = listOf("y" to "y"))), schema).use { pipeline ->
    pipeline.enqueue(Request(mapOf("x" to x), streaming = true), RequestCallbacks(onChunk = { chunk -> chunk.use { println(it.final) } }))
}
```

## Types

| Name | Summary |
|---|---|
| [Companion](Companion/index.md) | [common]<br>object [Companion](Companion/index.md) |

## Functions

| Name | Summary |
|---|---|
| [await](await.md) | [common]<br>fun [await](await.md)(session: [SessionId](../SessionId/index.md)): [Response](../Response/index.md)<br>Block until [session](await.md) completes; its response, or its failure. |
| [cancel](cancel.md) | [common]<br>fun [cancel](cancel.md)(session: [SessionId](../SessionId/index.md))<br>Cooperatively cancel an in-flight session; a completed one is a no-op, an unknown one fails with `NOT_FOUND`. |
| [close](close.md) | [common]<br>open fun [close](close.md)() |
| [enqueue](enqueue.md) | [common]<br>fun [enqueue](enqueue.md)(request: [Request](../Request/index.md)): [SessionId](../SessionId/index.md)<br>Submit a request; fails with `INVALID_ARGUMENT` naming the input a declared slot refuses.<br>[common]<br>fun [enqueue](enqueue.md)(request: [Request](../Request/index.md), callbacks: [RequestCallbacks](../RequestCallbacks/index.md)): [SessionId](../SessionId/index.md)<br>Submit a request with its hooks, delivered on the engine's thread. |
| [shutdown](shutdown.md) | [common]<br>fun [shutdown](shutdown.md)()<br>Drain in-flight work and stop; every accepted session completes and [await](await.md) still answers it. |