Skip to main content

Local AI cost, latency, prompt, and workflow tracking.

Project description

OpenHarness

Local AI cost and workflow tracking for engineering teams.

No cloud. No signup. SQLite by default.

Install

pip install quadrant-openharness
openharness setup --demo
openharness costs

Use whichever pip command points at Python 3.10+ on your machine: pip, pip3, or python -m pip.

The package installs both command names:

openharness costs
agentharness costs

Until the first PyPI release is published, install directly from GitHub:

pip install "git+https://github.com/Quadrant-Labs/openharness.git"

Then run:

openharness setup --demo
openharness costs

Why this exists

AI agents and AI-backed workflows can make thousands of model calls before anyone notices the bill. OpenHarness starts with the smallest useful wedge: track model calls locally, estimate cost, then show engineers where the money and latency go.

CLI-first usage

Run OpenHarness as a local OpenAI-compatible proxy:

openharness start openai --port 8787

Then point any OpenAI-compatible SDK or tool at it:

export OPENAI_BASE_URL=http://127.0.0.1:8787/v1
export OPENAI_API_KEY=sk-...

Your app keeps calling OpenAI normally. OpenHarness forwards the request, captures usage from the response, estimates cost, stores it in local SQLite, and shows it in:

openharness costs

For Python:

from openai import OpenAI

client = OpenAI(base_url="http://127.0.0.1:8787/v1")

For Node:

import OpenAI from "openai";

const client = new OpenAI({ baseURL: "http://127.0.0.1:8787/v1" });

If your SDK already honors OPENAI_BASE_URL, the environment variable alone may be enough.

Prompt previews are off by default in proxy mode. To store a local 240-character preview for each JSON request:

openharness start openai --record-prompt-preview

The proxy also has initial usage extraction for Anthropic and Gemini:

openharness start anthropic --port 8788
openharness start google --port 8789

Proxy mode currently estimates costs from non-streaming JSON responses that include provider usage metadata. Streaming calls are forwarded, but they may not be costed unless the provider returns parseable usage data.

Org gateway mode

For a team or org, run OpenHarness as a shared gateway and tag traffic by owner:

openharness start openai \
  --host 0.0.0.0 \
  --port 8787 \
  --org acme \
  --team platform \
  --service pr-review-bot \
  --env production

Apps can also tag individual requests with headers:

x-openharness-org: acme
x-openharness-team: platform
x-openharness-service: pr-review-bot
x-openharness-env: production
x-openharness-workflow: pr_reviews
x-openharness-step: review

Or set tags on the proxy process:

export OPENHARNESS_ORG=acme
export OPENHARNESS_TEAM=platform
export OPENHARNESS_SERVICE=pr-review-bot
export OPENHARNESS_ENV=production

Org showback:

openharness org --last 30d

Example sections:

Spend by team
Spend by service
Spend by environment
Spend by workflow
Spend by customer
Spend by provider/model

Budget policies:

openharness budget init
openharness budget check

Then enable hard-stop enforcement in the proxy:

openharness start openai --enforce-budgets --budget-file .openharness/budgets.json

Budget config shape:

{
  "budgets": [
    {
      "name": "PR review bot monthly hard stop",
      "limit_usd": 1000,
      "period_days": 30,
      "action": "block",
      "filters": {
        "service": "pr-review-bot"
      }
    }
  ]
}

Export for finance, platform, or dashboards:

openharness export --format csv --output usage.csv
openharness export --format json --output usage.json

Command shape

OpenHarness is meant to feel like a terminal tool first:

openharness setup
openharness start openai --team platform --service pr-review-bot --env production
openharness costs --last 7d
openharness org --last 30d
openharness budget check
openharness export --format csv --output usage.csv

The longer names still work when you want them:

openharness proxy --provider openai
openharness report --days 30
openharness org-report --days 30

Python API

The Python API is still useful for apps that want explicit workflow and step labels in code.

Manual tracking:

from openharness import tracker

tracker.record(
    provider="openai",
    model="gpt-5.5",
    input_tokens=5000,
    output_tokens=1200,
    workflow="create_pr",
    step="review",
    latency_ms=4200,
    prompt_name="pr_review",
)

Workflow tracking:

from openharness import tracker

with tracker.workflow("create_feature"):
    with tracker.step("research"):
        tracker.record("anthropic", "claude-sonnet-4-6", 2000, 900)

    with tracker.step("code"):
        tracker.record("openai", "gpt-5.4-mini", 8000, 2400)

OpenAI wrapper:

from openai import OpenAI
from openharness import track_openai

client = track_openai(OpenAI())
response = client.chat.completions.create(
    model="gpt-5.5",
    messages=[{"role": "user", "content": "Review this PR"}],
)

The wrapper records model, tokens, latency, estimated cost, workflow, step, status, and errors when the SDK response exposes usage data.

CLI

openharness init
openharness record --provider openai --model gpt-5.5 --input-tokens 5000 --output-tokens 1200 --workflow pr_reviews
openharness costs --last 30d
openharness org --last 30d
openharness scan
openharness start openai --port 8787
openharness budget check
openharness export --format csv --output usage.csv
openharness pricing
openharness doctor

scan is currently an alias for reporting local OpenHarness data. A future version can inspect source trees and provider logs.

Storage

By default OpenHarness writes to:

.openharness/openharness.db

Override it with:

export OPENHARNESS_DB=/path/to/openharness.db

Pricing catalog

Costs are estimates calculated from a small built-in catalog. Prices are per 1 million tokens and were checked on 2026-06-16 against official provider docs:

Provider billing can include regional processing, priority tiers, cache storage, search grounding, images, audio, discounts, taxes, and enterprise terms. Treat OpenHarness v0.1 numbers as directional until you wire in billing exports.

Development

python -m pip install -e .
PYTHONPATH=src python -m unittest discover -s tests
python -m openharness demo --reset
python -m openharness report

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

quadrant_openharness-0.1.1.tar.gz (29.3 kB view details)

Uploaded Source

Built Distribution

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

quadrant_openharness-0.1.1-py3-none-any.whl (28.3 kB view details)

Uploaded Python 3

File details

Details for the file quadrant_openharness-0.1.1.tar.gz.

File metadata

  • Download URL: quadrant_openharness-0.1.1.tar.gz
  • Upload date:
  • Size: 29.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for quadrant_openharness-0.1.1.tar.gz
Algorithm Hash digest
SHA256 23796546f4f8e6f71abda0f49b076433a15dae9aa151a43df253c052d094d53c
MD5 8f403cf77ddbc498c5bf1dd518b4c25b
BLAKE2b-256 900686d1c6b8d32854ce5514fd092aeb82b655eb82aaa9c878e6d71aa652c8bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for quadrant_openharness-0.1.1.tar.gz:

Publisher: publish.yml on Quadrant-Labs/openharness

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quadrant_openharness-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for quadrant_openharness-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cd12ac1d67439f94e5f088477aaf16869617f7ac61a1b7749c8194206988fb5f
MD5 e60140aa705bcc3d2f03a504b0076fe1
BLAKE2b-256 184900badd41c42ee617ff664bc2e0dd5f1505240480ea0c336c63807b2f7688

See more details on using hashes here.

Provenance

The following attestation bundles were made for quadrant_openharness-0.1.1-py3-none-any.whl:

Publisher: publish.yml on Quadrant-Labs/openharness

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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