Skip to main content

opencode-dashboard-server

FastAPI aggregation backend for the opencode-dashboard project. Reads opencode's local SQLite storage via the opencode db CLI and exposes a JSON + SSE API for the dashboard front end.

Install (PyPI)

pip install opencode-dashboard-server
# or with uv:
uv tool install opencode-dashboard-server

Requires:

  • Python ≥ 3.10
  • opencode CLI on the same host — the server shells out to opencode db "<SQL>" and never opens the SQLite file directly (it's WAL-mode and actively written while opencode runs).

Quick start

Configure once (interactive; writes ~/.config/opencode-dashboard/server.yaml), then serve:

opencode-dashboard-server configure
opencode-dashboard-server serve

configure walks you through port (default 8791), host (default 0.0.0.0), cors_origins (comma-separated; empty = built-in loopback whitelist), poll_seconds (default 5), and opencode_bin (default opencode). Empty input keeps the default.

serve accepts overrides: --port N, --host H, --config PATH (instead of the XDG file). Precedence for port/host: CLI flag > env PORT/HOST > config file > default.

Run one aggregator per opencode host:

uvicorn app:app --port 8791

or directly with uvicorn (still works — reads env/defaults only). Run on more hosts with different ports (8792, 8793, …) and list each in the front end's config (opencode-dashboard configure). Environment switches (used when no config file value is set):

  • DASHBOARD_CORS_ORIGINS — comma-separated CORS allow-list (defaults to the loopback dev origins localhost/127.0.0.1:5173 and :4173; tighten or widen for your deployment).
  • DASHBOARD_POLL_SECONDS — SSE poll interval in seconds (default 5).
  • OPENCODE_BIN — path to the opencode binary if it's not on PATH.

API

  • GET /health — liveness
  • GET /overview — whole-host aggregate (tokens by type + cost, session counts, updatedAt)
  • GET /projects — per-project rollups
  • GET /projects/{id} — one project's sessions (parent/child tree)
  • GET /sessions/{id} — per-model breakdown for one session (handles mid-conversation model switches)
  • GET /stream — SSE: updated events when the DB changes (polled ~5s)

JSON is camelCase, timestamps are epoch-ms. Full contract in the repo's API.md.

From source (development)

git clone https://github.com/GCS-ZHN/opencode-dashboard
cd opencode-dashboard/server
uv sync          # install deps (fastapi, uvicorn) + dev (pytest, httpx)
uv run pytest    # run tests
uvx ruff check . # lint

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opencode_dashboard_server-0.4.0.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

opencode_dashboard_server-0.4.0-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file opencode_dashboard_server-0.4.0.tar.gz.

File metadata

File hashes

Hashes for opencode_dashboard_server-0.4.0.tar.gz
Algorithm Hash digest
SHA256 012b30b4b3016a02149a49d1da22602629a4d477a615142552dc5f9228efe3d7
MD5 05adbf2a510442bf81ff5d1ffe1b6518
BLAKE2b-256 d2c7a66988f20c94d5b830640cd1607adc83ed455e0a113e9fb64150f7820c61

See more details on using hashes here.

File details

Details for the file opencode_dashboard_server-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for opencode_dashboard_server-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5be667d1f2cdf0c4d43420e27d3299f142053cc28df33f0ae8807b42e4f5d2de
MD5 2e33d0fd1520e6b702d250edcce860ad
BLAKE2b-256 d0fad04120325b40ccd4df2c0e8e0b9b0b95ff51985181fd4ccd6edd927d379e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page