---
title: "Write to a subprocess's stdin and/or close it"
method: POST
path: "/operations/{operationId}/subprocesses/{spid}/stdin"
tags: ["operation"]
---

# Write to a subprocess's stdin and/or close it

`POST /operations/{operationId}/subprocesses/{spid}/stdin`

Writes a chunk to the stdin of a live process inside the
running instance — `spid=1` targets the main process, `≥2` the
exec'd children.  Requires the process to have been started
with `stdin.close=false`; otherwise its pipe is already at EOF
and the call returns 409.

`close=true` (the default) signals EOF after writing `value`;
an empty `value` with `close=true` just closes the pipe.  A
client that serializes its own requests gets ordered writes;
concurrent requests to the same spid are safe but their order
is unspecified.

A 504 means the guest write timed out mid-call — the chunk may
or may not have been delivered (e.g. the process stopped
reading and the pipe is full), so blind retries can duplicate
data.

## Path parameters

- `operationId` string, uuid, required — A UUID string
- `spid` integer, required

## Request body

- ClosableStreamRepr — Stdin payload. Unlike output streams it is never truncated; instead it carries a `close` flag controlling the pipe's EOF.
  - `value` string, required — Content to write to stdin (may be empty for a close-only request)
  - `encoding` 'ascii' | 'base64' — Encoding of the content
  - `close` boolean — `true` (default) closes stdin (EOF) after writing `value` — the pre-existing one-shot behavior. `false` keeps the pipe open so more data can be sent later via `POST /operations/{operationId}/subprocesses/{spid}/stdin`.

## Response `204`

Chunk written (and/or stdin closed).

## Other responses

- `400` — Invalid spid or request body.
- `401` — Unauthorized - Invalid or missing authentication credentials. Either the `Authorization` bearer token is missing or invalid, or the `Project` header is missing.
- `403` — Forbidden - Token does not have sufficient permissions
- `404` — Not Found — the operation does not exist, or the worker has no live process with that spid (never spawned or already exited).
- `409` — Conflict — the operation is not a running instance, or the process's stdin is already closed (spawned without `close=false`, closed by an earlier request, or the process exited).
- `410` — Gone — the instance finished; there is no live process to write to.
- `425` — Too Early — no worker holds the operation yet, or the control channel is not up. Retry after `Retry-After`.
- `501` — Not Implemented — the instance runs a guest image that predates stdin streaming.
- `504` — Gateway Timeout — the guest write did not complete in time; the chunk may or may not have been written. Not safe to retry blindly.

---

[API](https://skmtc.net/nebius/apis/nebius-openai-compatible-inference-api.md) · [All operations](https://skmtc.net/nebius/apis/nebius-openai-compatible-inference-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/nebius/nebius-openai-compatible-inference-api/revisions/0fb323abba3c/schema)
