> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nika.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Server surfaces

> Separate the resident firer, authenticated nika serve HTTP and local model serving.

Three surfaces sound like servers but accept different clients.

| Surface | Job | HTTP workflow API |
| - | - | - |
| `nika serve` without `--bind` | Fires the `nika.yaml` project clock | no |
| `nika serve --bind` | Authenticated resident jobs and schedules | yes |
| `nika model serve` | OpenAI-compatible local inference provider | no |

> [!NOTE]
>
> **Live project control plane.** The released engine
> discovers `nika.yaml` from the working directory toward its
> ancestors. The file is optional when built-in defaults are enough. Its
> project-shape grammar is closed: `nika` ·
> `ceiling` · `arm` · `traces` ·
> `registry`. Direct runs and the cadence path
> (`nika arm` · `nika serve`) read the same file.

> [!NOTE]
>
> **The same client selects HTTP when `url` and
> `token` are present.** A served name such as
> `workflows/release.nika` (its path from the project root) goes
> directly to the server and needs no local engine or file. An explicit local
> path such as `./release.nika` needs a compatible local engine to
> capture an immutable snapshot. The released OpenAPI of
> `nika serve` 0.124.4 covers jobs, SSE events,
> cancellation, trace verification, the artifacts a settled job's sealed
> journal records (behind `run.artifacts()`), workflow listing,
> schedule read and write, stateless authoring
> (`POST /v1/compile`, behind `compile()`) and what a
> workflow's declared ACP route offers (behind `accessOffer()`). It has no
> `POST /v1/run`, job-list, or schedule list, delete, trigger
> or backfill route. The server owns its engine version; check its
> compatibility separately from the bundled local engine.

## Released OpenAPI routes (0.124.3, default server)

| Method and path | Contract |
| - | - |
| `GET /health` | unauthenticated health and supported capabilities |
| `GET /v1/openapi.json` | authenticated contract document |
| `POST /v1/check` | compact admission acknowledgement or typed workflow refusal |
| `POST /v1/compile` | stateless authoring: a candidate and a source-only check preview; creates no job and writes no file. Deterministic by default; on a server started with `--authoring-model`, a caller may opt in to one provider round (`/health` lists `compileNativeV2`, and `GET /v1/openapi.json` then also describes `CompileRequestV2`) |
| `POST /v1/jobs` | idempotent admission |
| `GET /v1/jobs/{id}` | durable job projection |
| `GET /v1/jobs/{id}/status` | current status |
| `GET /v1/jobs/{id}/events` | SSE event stream |
| `POST /v1/jobs/{id}/cancel` | cancellation action; 202 remains pending, 200 returns a completed observation |
| `GET /v1/jobs/{id}/trace/verify` | the CLI verifier's verdict on the journal the server wrote for that job |
| `GET /v1/jobs/{id}/artifacts` | a settled job's artifact manifest, read from its sealed journal and bound to its receipt |
| `GET /v1/jobs/{id}/artifacts/{name}` | one artifact's bytes, streamed and checked against the size and SHA-256 its journal records |
| `GET /v1/workflows` | contained names |
| `GET /v1/workflows/{name}` | path-free metadata |
| `GET /v1/access-offers/{name}` | what the sessions of that workflow's own declared ACP route offer now, read without a prompt (`/health` lists `accessSessionOffer`) |
| `GET /v1/schedules/{id}` | schedule status |
| `PUT /v1/schedules/{id}` | CAS-backed schedule apply |

The contract has no `POST /v1/run`, job-list, schedule-list, schedule-delete,
trigger or backfill routes, and no artifact upload or deletion.
`GET /v1/jobs/{id}/trace/verify` answers in the CLI's words, lower case: `ok`
(intact, but unsigned or sealed with a key the server does not weigh: `reason`
reads `unsealed` or `unattributable`), `sealed`, `anchored` and `replayed`
hold; `incomplete`, `tampered` and `broken` do not; `unavailable` means the
server holds no journal for that job. Both artifact routes answer only for a
settled job whose journal verifies sealed:
[Outputs and artifacts](https://docs.nika.sh/sdk/remote/artifacts.md) covers the client side, and the
[server runbook](https://docs.nika.sh/sdk/operations/server-runbook.md#artifact-downloads) what the
door exposes.

```sh theme={"system"}
nika serve --bind 127.0.0.1:18765 \
  --workflows ./workflows \
  --token-file .nika/serve.token
```

Useful flags beyond these three: `--state-root <dir>` (job state, default
`.nika/serve`), `--run-cost-ceiling <USD|none>` (per-job spend cap, default
1 USD), `--allow-remote` (acknowledge a non-loopback `--bind`; TLS belongs to
a reverse proxy) and `--authoring-model <provider/name>` (seat provider
authoring for `POST /v1/compile`). `nika serve --help` lists every flag.

The standalone engine also supports operator
[standing cost rules](https://docs.nika.sh/sdk/operations/standing-cost-policy.md):
`--cost-policy <RULE>` admits bounded runs on a named unpriced API route
without one-time cost review (`costStandingPolicyV1`). It does not enable
`--cost-review`, change the server's USD ceiling or authorize other tools.
Read the running server's capabilities and OpenAPI document before using
an optional surface; the npm package can bundle an older engine.

## Ask what a route offers

A workflow file can declare how its model calls travel: `run.access` (`via`,
`protocol`, `fallback`, `service_tier`) and `run.reasoning.effort`. A run
learns what its session offers on the way to its prompt, and says so only when
it refuses. From engine 0.124.3 a server can be asked first:

```ts theme={"system"}
const offer = await nika.accessOffer('workflows/brief.nika')
if (offer.status === 'not_applicable') {
  console.log(offer.reason)            // the file selects no ACP sessions
} else {
  for (const route of offer.routes) {
    if (route.status === 'unavailable') {
      console.log(route.profile, route.code, route.reason)
      continue
    }
    console.log(route.profile, route.model.status, route.effort?.offered, route.service_tier?.offered)
  }
}
```

* **The route is the file's.** The call names a served workflow and nothing
  else. The server asks only when the file declares `run.access.via` under
  `run.access.protocol: acp`; any other workflow answers
  `status: 'not_applicable'` with the reason, and no session is opened.
* **No prompt is sent.** The server opens each session as a run opens it,
  selects the file's model for that session only, lists what the session has
  for that model and ends it. `prompts_sent` is always `0`.
* **One row per session shape and model.** `completion` is the route's
  one-shot profile, which `infer:` tasks run under; `agent` is its agent
  session, which `agent:` tasks run in. `tasks` names the tasks of each row.
* **`effort.offered` is exact.** It holds the values a run accepts on
  `run.reasoning.effort` for that model. `effort.current` is what a run that
  declares no effort keeps on a session like this one. `service_tier.offered`
  holds the language's words, `standard` and `fast`.
* **A model the session does not list is a state, not an error.**
  `model.status` is then `not_offered`, with the models it does list in
  `model.offered`, and the efforts and tiers are `unobserved`.
* **A session that gives no offer is a row.** `status: 'unavailable'` carries
  the code a run would meet before its prompt (`NIKA-1803`, `NIKA-1804` or
  `NIKA-1805`) and a reason.
* **A row has a time.** `observed_at` and `fresh_until` say when it was read
  and until when the server serves it again: 60 seconds, 15 when unavailable.
  One reading runs at a time on the server, and a ninth concurrent request is
  refused with `NikaOperationError` (`access_offer_busy`).

The call has its own deadline, 100 seconds by default (`timeoutMs`), because a
first reading opens a session per row, and `signal` stops it. It needs a
server that lists `accessSessionOffer`: on another server, and on the local
engine, it rejects with `NikaCompatibilityError` before any request.

An offer authorizes nothing. A model, an effort or a tier can leave a route
between the offer and the run: `run()` is admitted as before, and the run
selects, reads back and refuses on its own session.
[Harness access](https://docs.nika.sh/guides/harness-access.md#ask-a-served-route-what-it-offers)
shows the document the server answers.

## Local application path

> [!TIP]
>
> **One client, local by default.** Import `Nika` from
> the package root and omit `url`. The client takes the engine
> from `bin`, then `NIKA_BIN` (both absolute paths), then
> the platform package npm installed with it; it never uses a
> `nika` found on your `PATH`. These examples target
> the published [0.124.4 SDK release](https://github.com/supernovae-st/nika-client/tree/v0.124.4).

```ts theme={"system"}
import { Nika } from '@supernovae-st/nika'

const nika = new Nika({ cwd: process.cwd() })
const run = await nika.run('workflow.nika')
const result = await run.result()
```

This path needs no resident server. These examples target the published
`@supernovae-st/nika@0.124.4` npm package (bundled engine 0.124.4). The
standalone engine CLI releases independently.

## Local model path

```sh theme={"system"}
nika model pull unsloth/Qwen3-4B-Instruct-2507-GGUF   # downloads into ~/.nika/models; prints the size first
nika model serve --model unsloth/Qwen3-4B-Instruct-2507-GGUF
```

`nika model serve` loads only models it has pulled (or a `.gguf` path), of
the Qwen3 family in 0.124.3, and serves them on `127.0.0.1:8712`. A workflow
reaches it as a local provider: export
`NIKA_LLAMACPP_BASE_URL=http://127.0.0.1:8712` and use
`model: llamacpp/<model id>`, as the banner prints. Application code does not
submit workflow jobs to it.

> [card] [Resident server](https://docs.nika.sh/sdk/operations/resident-server.md)
>
> Operate the default firer and opt-in HTTP door.

> [card] [Remote client](https://docs.nika.sh/sdk/remote/client.md)
>
> Configure the matching SDK transport.

> [card] [Local models](https://docs.nika.sh/guides/local-models.md)
>
> Run inference on your own machine.

> [card] [Deployment topologies](https://docs.nika.sh/sdk/operations/deployment-topologies.md)
>
> Choose a boundary by the job it owns.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.