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

# Payment channels and sessions

> What a session is, how its payment channel moves on chain, and how to read both.

Each request is one **session**. A session opens one **payment channel** on FLOP Network: an on-chain account between the payer and the miner that holds the escrow for this request. The miner answers through it and is paid from it.

## The life of a channel

| Stage | On chain | In the session record |
| - | - | - |
| Opened | The channel exists with the escrow locked. Opened against the miner's signed offer (`via: "offer"`) or by force-open (`via: "force"`). | `status: "running"`, `channel_id`, `on_chain.open_block` |
| Answered | Nothing yet. The reply and the miner's signed receipt travel off chain. | `status: "settling"`, `usage` |
| Settled | The miner posts the settlement and the escrow is paid out. | `status: "settled"`, `miner_paid`, `on_chain.outcome_tx` |
| Recovered | If the miner goes silent, the router closes the channel with a timeout or force-settle. | `status: "recovering"`, then the outcome |

Settlement timing and the recovery calls are on the [settlement](https://docs.floprouter.com/settlement.md) page.

## Read a session

```bash theme={null}
curl https://api.floprouter.com/v1/sessions/<session_id> -H "Authorization: Bearer $FLOPROUTER_API_KEY"
```

The session id is the `id` of the chat completion, and `flop.session_id`. The record carries:

| Field | Meaning |
| - | - |
| `status` | `running`, `settling`, `settled`, `refunded`, `recovering`, `failed`, `fraud` or `voided`. |
| `channel_id` | The payment channel, `0x` plus 64 hex characters. |
| `miner`, `endpoint`, `via` | Who served it and how the channel was opened. |
| `payer` | `address` and `kind`: who paid on chain (see [payer modes](https://docs.floprouter.com/payer-modes.md)). |
| `escrow`, `miner_paid` | What was locked, and what the settlement paid. |
| `router_fee` | Percent, amount and `status`: `pending`, `charged`, `not_charged` or `not_billed`. |
| `on_chain` | `open_block`, `outcome`, `outcome_block`, `outcome_tx`. |
| `attempts` | Every try, with the miner, stage, error and any recovery calls. |
| `reply` | The verified reply, to the key that made the request, once there is one. |

## Generation records Not live yet

A generation lookup reads the same session by its id:

```bash theme={null}
curl "https://api.floprouter.com/v1/generation?id=gen-..." -H "Authorization: Bearer $FLOPROUTER_API_KEY"
```

It returns tokens, `total_cost` in FLOP, finish reason, latency and the verified reply, with the full session under `flop`. Every chat response carries the id in the `X-Generation-Id` header as well as in `id`.

### Cost in the response

`usage.cost` is the request's cost in FLOP: escrow plus router fee. It is final when the session settles (`usage.cost_details.final`), and 0 for a session that is refunded. `usage.cost_details.upstream_inference_cost` is the escrow, split into prompt and completion by token share.

## List your sessions

```bash theme={null}
curl "https://api.floprouter.com/v1/sessions?limit=20" -H "Authorization: Bearer $FLOPROUTER_API_KEY"
```

## On the explorer

* A channel: `https://explorer.devnet.flop.network/channels/<channel_id>`
* A transaction: `https://explorer.devnet.flop.network/transactions/<outcome_tx>`
* A payer or miner: `https://explorer.devnet.flop.network/account/<address>`

In grant mode the explorer shows your address as the payer of the channel.


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