Skip to main content

Live token and cost visibility for Backboard apps. Run the server, open the UI, see usage in real time.

Project description

Backboard Usage

Live token and cost visibility for Backboard apps. See usage in real time as your agents run—no need to wait for the billing dashboard.


After you install the package

pip install backboard-usage

1. Start the server

In a terminal (leave it running):

backboard-usage-server

You should see: Live usage UI: http://localhost:8766

2. Open the UI

In your browser open: http://localhost:8766

You’ll see the usage dashboard (empty until your app sends data).

3. Add 3 lines to your Backboard app

Use UsageTracker so you only add a few lines:

from backboard_usage import UsageTracker

tracker = UsageTracker()

# After each agent response:
response = await client.add_message(...)
await tracker.record(response, agent="Idea Analyzer")  # use your agent name

# At the end of your run:
await tracker.finish()

That’s it. Open http://localhost:8766 and you’ll see all agents and token usage.


Optional: To try the UI without writing an app, clone this repo and run:

pip install websockets
python examples/demo_usage.py

(with the server and http://localhost:8766 open). You’ll see a fake run appear in the UI.


Wire format

Your app sends JSON over the WebSocket.

During a run (e.g. after each agent or message):

{
  "event": "usage",
  "total_tokens": 1234,
  "total_cost": 0.0123,
  "by_agent": {
    "Idea Analyzer": { "tokens": 600, "cost": 0.006 },
    "Market Researcher": { "tokens": 634, "cost": 0.0063 }
  },
  "by_model": {
    "openai/gpt-4o": { "tokens": 1234, "cost": 0.0123 }
  }
}

When the run finishes:

{
  "event": "done",
  "total_tokens": 1234,
  "total_cost": 0.0123,
  "by_agent": { ... },
  "by_model": { ... }
}

The UI shows This run, Total (all runs), and Run history.


Example: try the UI without an app

Clone this repo and run examples/demo_usage.py (with the server and http://localhost:8766 open). It sends fake usage so you can see the UI update—no Backboard API key needed. See examples/README.md.


Optional env

Variable Default Description
USAGE_WS_URL ws://localhost:8765 WebSocket URL for your app.

Documentation and links

When you push this repo to GitHub, update the repository URL in pyproject.toml (project.urls) and use it as the “Documentation” link (e.g. https://github.com/sapkota-aayush/BackboardOpenSource#readme).


For contributors (development from repo)

git clone https://github.com/sapkota-aayush/BackboardOpenSource.git
cd BackboardOpenSource
pip install -e .

To rebuild the UI and bundle it into the package:

cd usage-ui && npm ci && npm run build && cd ..
# Windows:
Copy-Item -Path usage-ui\dist\* -Destination backboard_usage\ui -Recurse -Force
# macOS/Linux:
cp -r usage-ui/dist/* backboard_usage/ui/

Then run backboard-usage-server or python usage_server.py.

Run tests:

python -m unittest tests.test_backboard_usage -v

License

MIT

Project details


Download files

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

Source Distribution

backboard_usage-0.2.1.tar.gz (65.4 kB view details)

Uploaded Source

Built Distribution

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

backboard_usage-0.2.1-py3-none-any.whl (63.8 kB view details)

Uploaded Python 3

File details

Details for the file backboard_usage-0.2.1.tar.gz.

File metadata

  • Download URL: backboard_usage-0.2.1.tar.gz
  • Upload date:
  • Size: 65.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for backboard_usage-0.2.1.tar.gz
Algorithm Hash digest
SHA256 48c9755a2a65031aa0144c1bb2fb63d8e360e84acc9fc942cfbb055273e4508c
MD5 70d9cd15927976696201e7c3bd628fc4
BLAKE2b-256 89257bc9c22e2350e69231a494fb5e27fb9b34553e8278c1c7365393c7597d77

See more details on using hashes here.

File details

Details for the file backboard_usage-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for backboard_usage-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5746390f2dd3ef06dbcca547e30ad415828d5b611367f7f8b24fceb5b14746c7
MD5 f5a8d78d0dfb00e74c2673bd5a024be4
BLAKE2b-256 d1267ee8d1d520f053b3483e55d47148e8d7c8221aae1265a66a8a5e0293a276

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