# River Console API for agents > Read River training runs, projects and their metrics with a River API key, > including the runs trainers stream to River Metrics, the key's account > balance, its live inference usage, and files of its per-request usage with > cost. These are the HTTP endpoints the Console web app uses. Requests and > responses are JSON. Base URL: https://console.river.ai (paths below are relative to it). ## Authentication Send a River API key (`rv_...`) as a bearer token: Authorization: Bearer $RIVER_API_KEY Create keys in the Console on the API Keys page. The key decides which account you read: - A personal key reads your personal runs, projects, balance and live usage, and exports your personal usage. - A team key reads the whole team's runs and projects, including runs started with other members' keys, and the team's balance and live usage. It exports the whole team's usage, whichever key made each request. Do not send a team selector. To read a team's data, use a team key. If you send the `X-River-Team` header, or `team_id` in the run query body, it must equal the key's own team; anything else returns 400. A personal key cannot select a team. The key is not read-only: it is the same credential used for training and metric logging. Keep it secret. Only the endpoints listed here accept API keys. Every other Console endpoint returns 401 for a key. ## Errors Errors have the body `{"error": "", "message": ""}`. - 400 `bad_request`: invalid parameter, body, cursor or team selector. - 401 `unauthorized`: missing, unknown, revoked or expired key, or an endpoint that does not accept keys. - 404 `not_found`: the run, project, metric stream or usage export is not in the key's account, or the account has no wallet. - 422 `metric_history_too_large` or `project_too_large`: the answer is over a size limit. Read less: use metric series, or select fewer runs. - 422 `invalid_range`: a usage export's time range is outside the allowed bounds. - 429 `too_many_exports`: the account already has 3 usage exports in progress. - 429 `rate_limited`: too many requests; wait `Retry-After` seconds. - 502 `bad_gateway`: River Metrics answered a live usage read unexpectedly. - 503 `service_unavailable`: metric storage or live usage is unavailable, or a chart read took too long. Retry later. ## Balance GET /api/billing/balance Reads the wallet of the key's account; it changes nothing. Amounts are in micro-USD (`*_micro_usd`, integers) and in USD (`*_usd`): - `balance`: the current balance the Console shows. - `credit_limit`: how far below zero the wallet may spend. - `held`: credit reserved for running full-weight GPU jobs. - `available`: `balance + credit_limit - held`. `team_id` is the team for a team key and `null` for a personal key. `status` is `active`, `frozen` or `closed`; only an active wallet can spend. `balance_updated_at` is when the balance last changed (RFC 3339, UTC): a usage charge, top-up, credit or adjustment. Status and credit-limit changes do not move it. Token usage is normally charged within seconds; GPU time and storage are charged hourly. An unchanged `balance_updated_at` with no new usage means nothing has changed, not that the balance is stale. It does not tell you whether recent usage has been charged yet. curl -s -H "Authorization: Bearer $RIVER_API_KEY" \ https://console.river.ai/api/billing/balance ## Live inference usage What the Console's Usage page shows on its Live tab: token usage and request outcomes of the account's recent inference requests, per model, in time buckets. Both reads take the same window: GET /api/usage/live?lookback_seconds=3600&step_seconds=5 GET /api/usage/errors?lookback_seconds=3600&step_seconds=5 - `step_seconds`: the bucket, one of 5, 10, 15, 30, 60, 300, 900 or 3600. - `lookback_seconds`: how far back the window reaches from now, 60 to 2764800 (32 days), at least one bucket and at most 1500 buckets. Use a larger step for a longer window: 3600/5 for 1 hour, 86400/300 for 24 hours, 604800/900 for 7 days. - `start` and `end`: a fixed span in place of `lookback_seconds`, as RFC 3339 instants, such as `start=2026-11-10T08:00:00Z&end=2026-11-10T09:00:00Z`. Without `end` the window runs to now. The span holds at most 1500 buckets. Nothing older than the answer's `retention_days` is returned. Both answer `query_now`, `start`, `displayed_through`, `step_seconds`, `lag_margin_seconds`, `retention_days`, `series` and `truncated`. Buckets lie in `[start, displayed_through)`, ascending by `bucket_start`; the newest `lag_margin_seconds` before `query_now` are held back until they are complete. Buckets are sparse: a bucket with nothing received is left out, which means no data, not a proven zero. `series` lists at most 50 models; `truncated` is `true` when more had data. Answers are shared for 2 seconds, so polling faster returns the same data. - `/api/usage/live`: one series per model (`model`, `buckets`), each bucket with `input_tokens` (cached included), `cached_input_tokens` and `output_tokens` of the requests that completed in it. A long request counts all at once when it finishes. - `/api/usage/errors`: final request outcomes. `all_models` is every model's buckets summed, complete even when `truncated`; `series` has one entry per model, with `model` `null` for requests rejected before a model was resolved. Each bucket counts `success`, `rate_limited`, `client_error`, `server_error`, `timeout`, `cancelled` and `unknown`; `cancelled` and `unknown` are not errors. These counts are approximate live data; data can be dropped on the way. They are not what you are billed: billed usage is on the Console's Daily tab. curl -s -H "Authorization: Bearer $RIVER_API_KEY" \ "https://console.river.ai/api/usage/live?lookback_seconds=3600&step_seconds=60" ## Per-request usage exports A usage export is a file with one row per billable request in a time range, with its tokens and cost. You ask for a range, River builds the file in the background, and the status call returns a download link once it is ready. POST /api/usage/requests/exports {"start": "...", "end": "..."} GET /api/usage/requests/exports/{id} GET /api/usage/requests/exports DELETE /api/usage/requests/exports/{id} ### Create an export `start` and `end` are RFC 3339 instants, such as `2026-11-15T00:00:00Z`, kept to the microsecond. The file holds the requests with `start <= created_at < end`, so consecutive ranges never overlap. Any other body field, or a body that is not this JSON, is refused with 400 `bad_request`. - `start` must be before `end` and no more than 365 days ago; `end` must not be in the future. Otherwise the answer is 422 `invalid_range`, with the allowed bounds in `earliest_start` and `latest_end`. - Requests take a few minutes to be recorded, so building waits until 10 minutes after `end`. A range that ends more recently is accepted and stays `pending` until `not_before`. - An account has at most 3 exports in progress (`pending` or `running`). A fourth is refused with 429 `too_many_exports`, whose `in_progress` lists their ids. - Asking again for a range you already exported returns that export with 200, while it is in progress or its file is kept, instead of starting new work. A failed or cancelled export does not count: the range is built again. A new export is answered with 202. Both answers carry the export, with the fields described under the status call; a new one is `pending`, with `not_before` (when building may start) and `estimated_requests`, an approximate row count for progress display that can be `null`. ### Status and download `GET /api/usage/requests/exports/{id}` returns the export: `id`, `status`, `start`, `end`, `not_before`, `created_at`, `estimated_requests`, and: - `status`: `pending`, `running`, `ready`, `failed` or `cancelled`. - `requests_written`: rows written so far. Compare it with `estimated_requests` to show progress. - `collected_at`: when the last rows were read. - `finished_at`: when the export finished. - `expires_at`: when the file is deleted, 5 days after `finished_at`. - `error`: why the export failed, when `status` is `failed`. - `file`, while a `ready` export's file is kept: `url`, `url_expires_at` (when the link stops working), `requests` (rows) and `bytes`. Fields without a value are `null`. An id that is not a UUID is refused with 400 `bad_request`; an export that is not in the key's account, or that was deleted, answers 404 `not_found`. The link is valid 12 hours, or until the file is deleted if that is sooner, and every status call returns a fresh link, so fetch the status just before you download. Download the link with a plain GET and no `Authorization` header: the link carries its own signature, and your API key must not be sent to it. The download can be resumed with a `Range` header; if the link has expired by then, fetch the status again for a fresh one. A range with tens of millions of requests takes hours to build, and exports from different accounts take turns. Poll the status every minute or so. Export each day once, after it has ended, rather than exporting the same days again. An export that cannot finish within 14 days fails; ask for shorter ranges. `GET /api/usage/requests/exports` answers `{"exports": [...]}`: the account's 50 most recent exports, newest first, without deleted ones. Their files carry no link (`url` is `null`); get the export for one. `DELETE /api/usage/requests/exports/{id}` answers 204. An export in progress is cancelled: it stays readable with status `cancelled` until you delete it again. A finished export (`ready`, `failed` or `cancelled`) is deleted with its file and then answers 404. Either way it no longer counts toward the limit, and the same range can be exported again. ### The file One gzip-compressed CSV file with one header row. Any gzip reader reads it whole, such as `gunzip` or `zcat`. Columns: - `request_id`: River's id for the request (see below); empty for a request recorded without one. - `created_at`: when the request finished, RFC 3339 in UTC with microseconds, such as `2026-11-15T00:00:03.120456Z`. - `model`: the model the request used. - `api_key_id`, `api_key_name`: the key that made the request; both are empty for a key that has since been deleted. - `type`: `inference` or `training`. - `input_tokens` (cached tokens included), `cached_input_tokens`, `output_tokens`, `training_tokens`. - `billing` and `cost_usd`: see below. Rows are not sorted across the whole file; sort by `created_at` when you need time order. A text cell that a spreadsheet would read as a formula (one that starts with `=`, `+`, `-`, `@`, a tab or a carriage return, such as a key name) gets a leading `'`. `request_id` is River's id for the request. For training and sampling it is the request id River's training API returns. Every OpenAI-compatible Chat Completions and Responses request that River accepts returns it in the `x-river-request-id` response header, so match a call to its row by that header; the response body's `id` is a different value. A request refused before it starts, such as one with an invalid key or body, has no id and no header. Calls to a dedicated deployment return the header too, but their rows are `not_billed`. The file has no request status: a request appears only if it produced usage. `billing` says how `cost_usd` was set: - `rated`: priced with the rates billing charged the request with, using billing's formula and rounding. `cost_usd` is that amount, a decimal with 6 places; an explicit zero rate gives `0.000000`. - `pending`: billing has not processed the request yet. `cost_usd` is empty. - `unpriced`: there was no rate for the model. `cost_usd` is empty. - `not_billed`: the request is not charged per token, such as usage on a dedicated deployment or full-weight GPU time. `cost_usd` is empty. For a request billed since River began recording the rates each billing run charges with, `rated` is exactly what billing charged. An older request, billed before that, is priced at your rate in force at the request's time, which differs from the charge in rare cases: a request made just before a rate change but charged just after it, at the new rate, and a rate removed from your rate history afterwards. Either way `rated` is not a record of the charge itself: in rare cases billing skips a request that was recorded late, and the request still shows as `rated`. A finished file never changes. A request can be recorded late with a `created_at` in the past, so a later export of the same range can contain rows the earlier file did not. To export a range again, delete the earlier export first; otherwise the create call returns it. ### Example Export one day, wait until it is ready, download the file, then delete the export, with `curl` and `jq`: API=https://console.river.ai/api/usage/requests/exports # 1. Create the export: 202 for a new one, 200 for a range already exported. EXPORT_ID=$(curl -sS --fail-with-body "$API" \ -H "Authorization: Bearer $RIVER_API_KEY" \ -H "Content-Type: application/json" \ -d '{"start": "2026-11-15T00:00:00Z", "end": "2026-11-16T00:00:00Z"}' \ | jq -r .id) # 2. Poll its status until it finishes. while :; do EXPORT=$(curl -sS --fail-with-body "$API/$EXPORT_ID" \ -H "Authorization: Bearer $RIVER_API_KEY") STATUS=$(jq -r .status <<<"$EXPORT") case "$STATUS" in ready) break ;; failed | cancelled) echo "$EXPORT"; exit 1 ;; esac echo "$STATUS: $(jq -r .requests_written <<<"$EXPORT") rows written" sleep 60 done # 3. Download from the link in that last status, without the API key, and # check the file. -C - resumes an interrupted download of this export. FILE="usage-$EXPORT_ID.csv.gz" if curl -sS --fail -C - -o "$FILE" "$(jq -r .file.url <<<"$EXPORT")" && gzip -t "$FILE"; then # 4. Only now delete the export and its file (204). curl -sS --fail-with-body -X DELETE "$API/$EXPORT_ID" \ -H "Authorization: Bearer $RIVER_API_KEY" else echo "Download incomplete: get the status again for a fresh link and" echo "repeat step 3, which resumes. The export is kept until then." exit 1 fi ## Runs ### Find runs POST /api/training/v2/runs/query Every body field is optional: {"limit": 50, "cursor": null, "status": "all", "users": [], "model": null, "query": null} - `limit`: 1 to 200 (default 50). Newest created first. - `cursor`: the previous page's `next_cursor`. `next_cursor` is `null` on the last page. - `status`: `all`, `active` or `inactive`. - `users`: emails of members whose keys started the runs; any of them match. - `model`: case-insensitive substring of the base model. - `query`: case-insensitive substring of a session tag key or value. Each run has `training_run_id`, `session_id`, `base_model`, `is_lora`, `lora_rank`, `created_at`, `status`, `last_seen`, `session_tags`, `name`, `projects` and `run_by` (emails of the members whose keys started it). curl -s https://console.river.ai/api/training/v2/runs/query \ -H "Authorization: Bearer $RIVER_API_KEY" \ -H "Content-Type: application/json" \ -d '{"limit": 20, "status": "active"}' Other run lists: - `GET /api/training/runs?limit=50&offset=0`: runs by latest activity. - `GET /api/training/overview/runs`: the 50 most recently active runs, each with `has_failed_requests`. ### One run - `GET /api/training/runs/{training_run_id}`: request counts, latest checkpoint step, worker lease and live capacity. - `GET /api/training/runs/{training_run_id}/requests?limit=50&per_type=false`: request metadata (type, status, token counts, error). No prompts or outputs. `per_type=true` applies the limit to each request type. - `GET /api/training/runs/{training_run_id}/projects`: the projects the run belongs to. ## Run metrics A run records metrics in streams. Each training process, and each restart or resume, writes its own stream; streams are never merged. 1. List streams and metrics: GET /api/training/runs/{training_run_id}/metric-catalog?limit=500&cursor=... Returns `streams` (`stream_id`, `source`, `started_at`, external run details), `metrics` (`stream_id`, `name`, `label`, `group`, `default_x`, `available_x`, `hidden`) and `next_cursor`. `limit` is 1 to 1000. 2. Read one metric from one stream: GET /api/training/runs/{training_run_id}/metric-series?stream_id=...&metric=train/loss&x=history_step - `x`: `history_step` (default), `wall_time` (epoch milliseconds), `elapsed` (seconds) or `metric:`. The catalog's `default_x` is the axis the run declared. - `x_min`, `x_max`: optional range. - `max_points`: 8 to 2000 (default 2000). Over it, the series is downsampled to each bucket's first, last, lowest and highest points and `downsampled` is `true`. Narrow `x_min`/`x_max` for full resolution. Returns `points` (`x`, `y`, `history_step`, `event_seq`, `logged_at`), ordered by `x`, plus `downsampled` and `missing_x` (events that recorded the metric without this axis). 3. Read every recorded value, unsampled: GET /api/training/runs/{training_run_id}/metric-history Returns `streams`, each with its `metrics` and `events` (`event_seq`, `history_step`, `logged_at`, `elapsed_s`, `values`, `axes`). Refused with 422 `metric_history_too_large` over 50,000 events, 500,000 values, 20 MiB or 1,000 streams; use metric series then. curl -s -H "Authorization: Bearer $RIVER_API_KEY" \ "https://console.river.ai/api/training/runs/$RUN_ID/metric-catalog" ## Projects A project groups runs and shares chart settings. - `GET /api/projects?limit=50&search=...&cursor=...`: projects, most recently active first. `search` is a case-insensitive substring of the name. - `GET /api/projects/{project_id}`: details, including pinned metrics in `view_settings.pinned_metrics`. - `POST /api/projects/{project_id}/runs/query` with `{"limit": 50, "cursor": null}`: member runs, most recently added first. Each run has `cell` and `training_run_id`. `unavailable_runs` lists members that can no longer be read, for example deleted runs. ### Project charts Charts read a selection of at most 100 runs, each written as `{"cell": "...", "training_run_id": "..."}` from the project runs query. - `POST /api/projects/{project_id}/metric-catalog` with `{"runs": [...]}`: the selection's charts (`name`, `label`, `group`, `default_x`, `run_count`), plus the selected `runs` and `unavailable_runs`. - `POST /api/projects/{project_id}/metric-series` with `{"runs": [...], "metric": "train/loss", "x": "history_step", "max_points": 20000}`: one series per stream (`training_run_id`, `stream_id`, `points`, `downsampled`, `missing_x`). `x` is a chart axis from the catalog: `history_step` or `metric:`. `max_points` is 1000 to 100000 across all runs; each stream gets an equal share of at least 16 and is downsampled above it. Chart points are for plotting, not an export. For exact values, read each run's metric history. curl -s https://console.river.ai/api/projects/$PROJECT_ID/metric-series \ -H "Authorization: Bearer $RIVER_API_KEY" \ -H "Content-Type: application/json" \ -d '{"runs": [{"cell": "c1", "training_run_id": "'"$RUN_ID"'"}], "metric": "train/loss", "x": "history_step"}' ## River Metrics Runs that a trainer streams to River Metrics (`https://metrics.river.ai`), such as Cork pretraining, are read under `/api/metrics-v2`. They are what the Console's Metrics pages show. Their runs and projects are separate from the training runs and projects above: an id from one is not found in the other. A run is one launch of a trainer. A crash restart is a new run in the same fork (`fork_ref`); a branch from a checkpoint is a new fork in the same lineage (`lineage_ref`). Reads draw one line per fork, each step from the fork's newest run. A series is a metric with one complete label set, such as `{"layer": "7"}`; an unlabeled series is `{}`. ### Runs and projects - `GET /api/metrics-v2/runs`: runs, newest first. `limit` is 1 to 1000 (default 100); pass the previous page's `cursor`, `null` on the last page. Optional filters, all of which must match: - `q`: case-insensitive substring of the name or external ref; `*` matches any text. - `state`: comma-separated `running`, `finished`, `failed`. - `kind`: comma-separated `start` (a new lineage), `branch` (a new fork off another run), `restart` (continues an earlier run's fork). - `project`: exact project name. - `registered_after`: RFC 3339 time. - `include_last_step=false`: a faster list with `last_step` left `null`. - `GET /api/metrics-v2/runs/{run_id}`: the `run`, plus every run of its `fork` and its `lineage`, oldest first. - `GET /api/metrics-v2/projects?limit=1000&cursor=...&q=...`: projects by name; `cursor` is `null` on the last page. - `GET /api/metrics-v2/projects/{project_id}`: the project, its member `runs` and its saved `view` (`pinned_metrics`, `x_axis`, `label_filters`). Each run has `id`, `external_ref`, `name`, `fork_ref`, `parent_ref`, `lineage_ref`, `state`, `config`, `metadata`, `projects`, `last_step` and `created_at`. ### Run metrics 1. List the metrics of a run's fork: GET /api/metrics-v2/runs/{run_id}/metrics Each entry has `metric`, `series` (its number of label sets), `label_keys` (each label key with its number of values), `points`, `first_step` and `last_step`. 2. Read the last, lowest and highest value of each series: POST /api/metrics-v2/summary {"run": "...", "metrics": ["train/loss"], "labels": null} `metrics` names at most 100 metrics; empty or absent means every metric. Returns `metrics`, one entry per series (`metric`, `labels`, `last`, `min`, `max` as `{"step", "value"}`, `steps`, `nonfinite`), and `truncated` when more series matched than were returned. 3. List the label sets of one metric: POST /api/metrics-v2/series/catalog {"runs": ["..."], "metric": "router/requested/cv", "labels": null, "limit": 100, "cursor": null} Returns `series` (`labels`, `forks`, `first_step`, `last_step`) and `cursor`, `null` on the last page. `limit` is 1 to 1000. 4. Read chart lines of one metric: POST /api/metrics-v2/series/lines {"runs": ["..."], "metric": "train/loss", "x": {"kind": "step"}, "budget": 2000} - `runs`: 1 to 100 run ids. Send every run of a fork to read the fork's line; one run of a fork reads that run alone. - `labels`: a label selector; every series when absent. - `x`: `{"kind": "step"}` (default) or `{"kind": "metric", "metric": "train/tokens", "labels": {}}`, the value one series of another metric has at the same step. - `step_min`, `step_max`: optional inclusive bounds. - `budget`: 16 to 100000 points over all lines (default 2000); each line gets an equal share. - `line_limit`: 1 to 500 (default 500). - `bucket_width`: optional steps per bucket, so lines of several runs share bucket edges. Returns `lines`, one per fork and label set (`fork_ref`, `runs`, `labels`, `points`, `steps`, `downsampled`, `nonfinite`, `missing_x`, `last`, `min`, `max`), and `truncated` when more lines matched than were returned. Each point is one bucket of steps: `step` (its lowest), `x`, `min`, `max`, `first`, `last` and `steps`. A line's `last`, `min` and `max` cover every value in the step range, not only the sampled points; they are `null` when unavailable. Statistics and points cover finite values only; `nonfinite` counts the values left out. ### Label selectors `labels` in a summary, series catalog or lines read selects series: - absent, `null` or `{}`: every series of the metric, `{}` included. - `{"layer": "7"}`: series whose `layer` is `7`; other keys are allowed. - `{"layer": ["0", "7"]}`: any of the listed values. Several keys must all match. - `[{"layer": "7"}, {}]`: exactly these label sets, at most 500. A key filter never matches the unlabeled series `{}`. curl -s https://console.river.ai/api/metrics-v2/series/lines \ -H "Authorization: Bearer $RIVER_API_KEY" \ -H "Content-Type: application/json" \ -d '{"runs": ["'"$RUN_ID"'"], "metric": "train/loss", "budget": 2000}' ## Typical workflows - Watch inference traffic: poll live usage and errors with a short lookback and step; a bucket's tokens divided by `step_seconds` is its rate. - Fetch a day's per-request costs: after the day has ended, create an export for it, poll its status until `ready`, download `file.url`, then delete the export. - Inspect a run: find it with the run query, list its metrics with the catalog, then read metric series (or the full history when it fits). - Compare runs in a project: list projects, page the project's runs, read the selection's chart catalog, then read each chart's series. - Inspect a River Metrics run: find it in the metrics-v2 run list, read its detail for the run ids of its fork, list its metrics and read the summary, then read lines with every run id of the fork.