# API endpoints (selected)

Source: https://nodedocs.mor.org/reference/api-endpoints

## Agent Instructions

- Non-browser fetches of page URLs on this site return clean Markdown (not the JS UI). Prefer `https://nodedocs.mor.org/llms-full.txt` for the full corpus, or `https://nodedocs.mor.org/llms.txt` for the index.
- Per-page Markdown is also at `<page-url>.md` (homepage: `https://nodedocs.mor.org/index.md`).
- Docs search MCP: `https://nodedocs.mor.org/mcp` (discovery: `https://nodedocs.mor.org/.well-known/mcp`).
- Never invent contract addresses, chain IDs, token addresses, or live bid/model counts. Cite Networks and tokens; link active.mor.org for live data.
- Never claim Morpheus runs inference — independent providers do. Opening a session escrows MOR; it does not spend it.

This page gives prose context for the endpoints integrators reach for first when calling **the proxy-router HTTP API** (i.e. the API your local node exposes on `:8082`). The complete schema lives at [`proxy-router/docs/swagger.yaml`](https://github.com/MorpheusAIs/Morpheus-Lumerin-Node/blob/main/proxy-router/docs/swagger.yaml) and is browsable at `http://localhost:8082/swagger/index.html` when your node is running.

> If you're looking for the **hosted** OpenAI-compatible Morpheus product (no node required), that is a separate service — see [Inference API overview](/inference-api/overview) and [apidocs.mor.org](https://apidocs.mor.org).

## Authentication

All endpoints require **Basic Authentication**:

```
Authorization: Basic <base64(username:password)>
```

See [API auth](/reference/api-auth).

---

## Chat completions

`POST /v1/chat/completions`

OpenAI-compatible chat. The request body is forwarded to the provider; you don't need a `model` field — it's set by the provider based on `session_id`.

| Header | Purpose |
|--------|---------|
| `session_id` (hex32) | Required for remote provider routing |
| `x-morpheus-history` | Optional per-request history override. `off` neither stores this exchange nor prepends stored history to it, whatever `PROXY_STORE_CHAT_CONTEXT` / `PROXY_FORWARD_CHAT_CONTEXT` say. `on` / `default` (or omitted) keep the node's policy. A client can opt **out** of history for one request; it cannot turn history **on** where the operator disabled it. Anything else returns `400`. |

```bash
curl --location 'http://localhost:8084/v1/chat/completions' \
  --header 'Accept: application/json' \
  --header 'session_id: 0x8e12df2f764b416c0ea1936a253c2a4be01005651c2d73f22dd0d72520f93ca1' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
  --data '{
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Tell me about AI."}
    ],
    "stream": false,
    "max_tokens": 2048
  }'
```

Response: `200 OK`, `text/event-stream` (streaming) or `application/json`.

---

## Audio transcriptions

`POST /v1/audio/transcriptions`

`multipart/form-data`. The body is forwarded — any field the provider accepts will pass through. Common fields:

| Field | Notes |
|-------|-------|
| `file` | Audio file |
| `s3_presigned_url` | Pre-signed URL for secure file access |
| `language` | |
| `response_format` | `json` / `text` / `srt` / `verbose_json` / `vtt` |
| `timestamp_granularities[]` | `word` / `segment` |
| `output_content` | |
| `enable_diarization` | Boolean |

```bash
curl --location 'http://localhost:8084/v1/audio/transcriptions' \
  --header 'session_id: 0x9fe60aa88c4e8d44414431dd565353efb762a923d639f54f856b3ac657e16263' \
  --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
  --form 'file=@"/path/to/harvard.wav"'
```

---

## Audio speech (TTS)

`POST /v1/audio/speech`

JSON. Common fields: `input` (required), `voice`, `response_format` (`mp3`/`opus`/`aac`/`flac`/`wav`/`pcm`; default `mp3`), `speed`.

```bash
curl --location 'http://localhost:8085/v1/audio/speech' \
  --header 'session_id: 0xf38101fbd00ed4db25444e9d9a65b737d4cd3d464da3aeb118b749c10ee48b10' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
  --data '{"input": "Lorem ipsum dolor sit amet.", "voice": "af_alloy"}'
```

---

## Embeddings

`POST /v1/embeddings`

```bash
curl --location 'http://localhost:8084/v1/embeddings' \
  --header 'session_id: 0xbd5585da9c1e62b4ac89152e7770cdc2779400afa181f831484c60aabc2422f4' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
  --data '{ "encoding_format": "float", "input": "The quick brown fox..." }'
```

---

## Decisions

`POST /v1/decisions` — permission `decisions`

Non-streaming JSON. Body is the TypeSafe System One / OpenRouter Decisions core (`state` + `questions`). Response is `{ model, answers, usage }`. The provider's `models-config.modelName` overwrites any client `model` field (same as embeddings).

```bash
curl --location 'http://localhost:8082/v1/decisions' \
  --header 'session_id: 0x...' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
  --data '{
    "state": "Ticket: invoice dispute, customer asks chargeback timeline.",
    "questions": {
      "dept": {
        "type": "choice",
        "instructions": "Route the ticket.",
        "criteria": {
          "billing": "Payment, invoice, refund",
          "technical": "Product bug or outage",
          "general": "Other"
        }
      },
      "urgent": {
        "type": "noul",
        "instructions": "Needs same-day human review?"
      }
    }
  }'
```

See [Decisions](/consumers/decisions) for consumer how-to and [models-config.json](/reference/models-config) for provider `apiType=decisions` rows.

---

## Video jobs

`POST /v1/video/quote` · `POST /v1/video/jobs` · `GET /v1/video/jobs` · `GET /v1/video/jobs/:id` — permission `video_jobs`

For models whose `ModelType` is `VIDEO`. A video job runs asynchronously: you submit it on a session, and the node reads its status from the provider until the job ends. The node never opens a session for a video job and never closes one early: you close it when you are done, and a session that reaches its end is closed by the node's normal expiry auto-close, as for any session.

| Route | Notes |
|-------|-------|
| `POST /v1/video/quote` | Body: the job (below) plus `model`, the on-chain model id (or send it in the `model_id` header). Opens nothing. Returns `data`, one entry per bid of the model in rating order: `provider`, `bid_id`, `price_per_second_wei`, `session_seconds` (already raised to the contract minimum), `quote_seconds` (what the job uses of a session, before that raise), `session_cost_wei` and `resolved` (the job with the model's defaults applied), or `error` for a provider that cannot take the job. |
| `POST /v1/video/jobs` | Header `session_id` required. Body: `prompt` (required, up to 4000 bytes) and optional `duration_seconds`, `aspect_ratio`, `resolution`, `generate_audio`, `image_url` (a public https URL) or `image_b64` (base64 or a data URI; JPEG, PNG or WebP, up to 10 MiB; only where the model offers it). Omitted fields take the model's defaults. Returns `201` with the job. |
| `GET /v1/video/jobs` | Every job this node tracks, newest first. |
| `GET /v1/video/jobs/:id` | One job as the node last read it: `status` (`queued`, `running`, `succeeded`, `failed`, `expired`, `cancelled`), `video_url` once it succeeded, `expires_at` when the vendor documents it, `error` (`code`, `message`). |

The session routes do the rest. Open the session on the bid you chose with [`POST /blockchain/bids/:id/session`](#open-session-by-bid-id) and `{"sessionDuration": <session_seconds>}`. `session_cost_wei` is what the compute is worth. The MOR the open locks comes from [the estimate](#estimate-a-session-before-opening) with `sessionDuration=<session_seconds>&bidId=<bid_id>`. Several jobs can share a session while their quotes add up to no more than its length. Close it with [`POST /blockchain/sessions/:id/close`](#close-session) when you are done.

```bash
curl -s -u 'admin:admin' -X POST 'http://localhost:8082/v1/video/quote' \
  -H 'Content-Type: application/json' \
  -d '{"model": "0x…", "prompt": "A paper boat drifting down a rain gutter", "duration_seconds": 5, "resolution": "720p"}'

curl -s -u 'admin:admin' -X POST 'http://localhost:8082/v1/video/jobs' \
  -H 'session_id: 0x…' \
  -H 'Content-Type: application/json' \
  -d '{"prompt": "A paper boat drifting down a rain gutter", "duration_seconds": 5, "resolution": "720p"}'
```

`video_url` is the vendor's own download link: anyone who holds it can fetch the file until it expires. The node does not store or proxy the file.

Errors: `400` bad request (for example no `prompt` or no `session_id`), `404` job, session or provider not found, `422` the provider refused the job (its message says why, for example a session too short for the quote), `502` your node could not send the job (for example a failed TEE attestation), or the quote could not read the model's bids or the contract's session bounds. A provider that does not answer is not a `502`: the submit still returns `201` with `vendor_task_id` empty and your node sends the job again, and on a quote that bid gets an `error` entry. `503` video jobs not enabled on this node.

See [Video jobs](/consumers/video) for the consumer how-to and [models-config.json](/reference/models-config#video-models) for provider `apiType` rows.

---

## Get providers

`GET /blockchain/providers`

Query params: `offset`, `limit`, `order`.

```bash
curl --location 'http://localhost:8082/blockchain/providers' \
  --header 'Authorization: Basic YWRtaW46YWRtaW4='
```

---

## Get models

`GET /blockchain/models`

`ModelType` is one of `LLM`, `STT`, `TTS`, `EMBEDDING`, `DECISIONS`, `VIDEO`, `UNKNOWN`. Use it to choose the appropriate endpoint family. A `VIDEO` model takes [video jobs](#video-jobs), not chat. Full sample response in [`proxy-router/docs/swagger.yaml`](https://github.com/MorpheusAIs/Morpheus-Lumerin-Node/blob/main/proxy-router/docs/swagger.yaml).

The registry read is cached in the node for **30 seconds**. Your own `POST /blockchain/models` and `DELETE /blockchain/models/:id` invalidate it immediately; a model registered by someone else can take up to 30 s to appear.

### Model price index

`GET /blockchain/models/prices` — permission `get_bids`

One call that returns the live per-second price range for **every** registered model, so a client can rank by cost without one bid request per model. Cached for 60 seconds.

```json
{
  "prices": [
    { "model_id": "0x…", "min_price_per_second_wei": "10000000000", "max_price_per_second_wei": "25000000000", "bid_count": 3 },
    { "model_id": "0x…", "min_price_per_second_wei": "", "max_price_per_second_wei": "", "bid_count": 0 }
  ],
  "failed_model_ids": []
}
```

Empty price strings with `bid_count: 0` mean **no live provider**, not "free". `failed_model_ids` lists models whose bids could not be read this time; the rest of the answer is still returned. Rows are not sorted — order them client-side.

---

## Session duration bounds

`GET /blockchain/sessions/duration` — permission `get_sessions`

Reads `MIN_SESSION_DURATION` and `getMaxSessionDuration()` from the deployed contract so clients stop hardcoding them:

```json
{ "min_seconds": "300", "max_seconds": "86400" }
```

---

## Estimate a session before opening

`GET /blockchain/models/:id/session/estimate?sessionDuration=3600[&directPayment=false][&bidId=0x…]` — permission `get_bids`

Returns the MOR amount `openSession` will pull from the wallet and every input it was derived from. Without `bidId` it quotes the **top-scored** bid — the one an unattended open tries first. With `bidId` it quotes that bid (must be one of the model's rated bids, `400` if the value is not 32 bytes).

```json
{
  "stake_wei": "…",
  "session_cost_wei": "…",
  "mor_supply_wei": "…",
  "emissions_budget_wei": "…",
  "price_per_second_wei": "…",
  "duration_seconds": "3600",
  "direct_payment": false,
  "bid_id": "0x…",
  "top_bid_provider": "0x…",
  "top_bid_score": 0.98,
  "explanation": "…"
}
```

`stake_wei` is what the contract locks; `session_cost_wei` (`price × duration`) is what the compute is worth. They differ by roughly `supply ÷ budget` — several hundred × — and confusing them makes the desktop app look like it is charging hundreds of times the real price. Formula in [Sessions: stake, close, claim](/concepts/sessions-stake-close-recover#how-much-mor-does-an-open-lock).

---

## Open session by model ID

`POST /blockchain/models/:id/session`

| Body field | Required | Notes |
|------------|----------|-------|
| `sessionDuration` | yes | Seconds. Must be within the [contract bounds](#session-duration-bounds). |
| `directPayment` | optional | Pay the provider from your escrowed amount at close instead of from the emissions pool. The locked amount is the same either way; only who pays the provider changes. |
| `failover` | optional | Try the next rated provider if the first handshake fails. |
| `rejectExisting` | optional | Refuse to open when this wallet already has a live session for the same model and return **`409 { "existingSessionID": "0x…" }`** instead. Off by default so callers that intentionally run parallel sessions keep working. |
| `omitProvider` | optional | Exclude one provider address from bid selection. |

```bash
curl --location 'http://localhost:8084/blockchain/models/0xe086adc275c99e32bb10b0aff5e8bfc391aad18cbb184727a75b2569149425c6/session' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
  --data '{ "sessionDuration": 600, "failover": false, "directPayment": false }'
```

Response includes `sessionID`.

### Open session by bid ID

`POST /blockchain/bids/:id/session`

Same as above but targets one specific bid instead of running the failover loop. Fields:

| Body field | Required | Notes |
|------------|----------|-------|
| `sessionDuration` | yes | Seconds |
| `directPayment` | optional | Same meaning as above. Earlier releases forced staking on this route; a consumer picking their own provider can now pay directly. |
| `rejectExisting` | optional | Same `409` behaviour as above, keyed on the bid's model. |
| `maxStakeWei` | optional | Reject the open before anything is broadcast if the computed stake exceeds this cap. Also switches this open onto the gateway stake formula — see [Companion gateway mode](/prosumers/companion-gateway-mode#stake-cap-on-open-by-bid-maxstakewei). |

Open-by-bid, close, and withdraw also accept an optional `X-Gateway-Operation` idempotency header on nodes running with `GATEWAY_JOURNAL_PATH`; when sent, responses gain a `progress` object. Nodes without the env, and calls without the header, return the same bodies as before. Details in [Companion gateway mode](/prosumers/companion-gateway-mode#operation-journal-x-gateway-operation).

---

## Close session

`POST /blockchain/sessions/:id/close`

```bash
curl --location 'http://localhost:8084/blockchain/sessions/0xf343b654cc8a21d0666c38606146ae68ef67b4445643deba02991a72f0d09785/close' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
  --data '{}'
```

Response includes the on-chain transaction hash.

**Note on refunds:** **unused** stake is `safeTransfer`'d back in this same transaction. The **used stipend** may be parked in `userStakesOnHold` with `releaseAt = startOfTheDay(min(closedAt, endsAt)) + 1 day` — including same-day natural/late close. Call `withdrawUserStakes` (below) after the timelock. See [Sessions: stake, close, claim](/concepts/sessions-stake-close-recover).

---

## List sessions for a wallet

`GET /blockchain/sessions/user?user=0x…&offset=0&limit=20&order=desc`

```bash
curl --location -u 'admin:admin' \
  'http://localhost:8082/blockchain/sessions/user?user=0xYOUR_WALLET&offset=0&limit=20&order=desc'
```

Variant for IDs only: `GET /blockchain/sessions/user/ids?user=0x…`. Fetch one: `GET /blockchain/sessions/0x<sessionId>`.

---

## Inspect and claim day-locked on-hold balance

Both endpoints operate on the proxy-router's configured wallet. `iterations` caps how many on-hold rows the contract inspects or withdraws; it defaults to `255` and accepts values from `1` through `255`.

```bash
# Split the queue into releasable and still time-locked MOR
curl -u 'admin:admin' \
  'http://localhost:8082/blockchain/stakes/onhold?iterations=20'

# Claim rows whose releaseAt has passed
curl -u 'admin:admin' \
  -X POST 'http://localhost:8082/blockchain/stakes/withdraw' \
  -H 'Content-Type: application/json' \
  -d '{"iterations":20}'
```

The read response is `{ "available": "...", "hold": "..." }`. The withdrawal response contains the on-chain transaction hash. An empty request body uses the default iteration limit.

To bypass the node, send the same transaction to the Diamond (Inference) contract directly:

```bash
cast send 0x6aBE1d282f72B474E54527D93b979A4f64d3030a \
  "withdrawUserStakes(address,uint8)" 0xYOUR_WALLET 20 \
  --rpc-url https://mainnet.base.org \
  --private-key "$PRIVATE_KEY_OF_DELEGATEE"
```

Function selector: `0xa98a7c6b`. The caller must be the delegatee allowed for that consumer (usually the same key your consumer node uses). See [Where is my MOR? → Bucket 2](/ai/where-is-my-mor#bucket-2-on-hold-queue-used-stipend-day-lock).

---

## Wallet and HD accounts

`GET /wallet` — permission `get_wallet`

```json
{ "address": "0x…", "kind": "mnemonic", "derivationPath": "0" }
```

`kind` is `mnemonic`, `privateKey`, or `env` (`WALLET_PRIVATE_KEY`). `kind` and `derivationPath` are omitted on releases that predate them and on wallets the node cannot classify, so read `address` first and treat the rest as advisory.

`POST /wallet/derivationPath` — permission `set_wallet`

```bash
curl -u 'admin:admin' -X POST 'http://localhost:8082/wallet/derivationPath' \
  -H 'Content-Type: application/json' -d '{"derivationPath": "1"}'
```

Re-derives the active key from the mnemonic **already stored on the node** and switches the wallet to that HD account, so a client never has to hold the seed phrase to change accounts. A bare index (`"0"`, `"1"`, …) is relative to `m/44'/60'/0'/0` — the same numbering MetaMask uses for Account 1, Account 2, …; a full path is accepted too. Returns the new `address`. `400` if the wallet was imported as a raw private key (`kind: privateKey`) or comes from the environment, or if the path is not derivable. The change is persisted and takes effect immediately for every subsequent call.

---

## Reload models config (provider)

`POST /config/models/reload` — permission `system_config`

Re-reads `models-config.json` and swaps the in-memory model table without restarting the node, so open sessions are not cut. Queues a model-health sweep. A file that fails to parse returns `400` and leaves the running table in force.

```bash
curl -s -X POST -u 'admin:yourpassword' http://localhost:8082/config/models/reload
# {"added":["0x…"],"removed":[],"healthSweepQueued":true}
```

`404` on releases that predate the endpoint — restart instead. Full notes: [models-config.json → Reload without a restart](/reference/models-config#reload-without-a-restart).

`GET /config` (same permission) returns the sanitised running config plus a `GatewayCapabilities` array (`stake-limit-v1`, `operation-journal-v1`, `transaction-progress-v1`) that companion gateways feature-detect against — see [Companion gateway mode](/prosumers/companion-gateway-mode#capability-discovery).

---

## Full schema

The complete OpenAPI schema lives at [`proxy-router/docs/swagger.yaml`](https://github.com/MorpheusAIs/Morpheus-Lumerin-Node/blob/main/proxy-router/docs/swagger.yaml). When your proxy-router is running, the same spec is browsable interactively at `http://localhost:8082/swagger/index.html`.
