Skip to content

feat: connect OpenAI and Anthropic API usage monitors - #43

Open
pekth wants to merge 5 commits into
mainfrom
feat/openai-api-usage
Open

pekth wants to merge 5 commits into
mainfrom
feat/openai-api-usage

Conversation

@pekth

@pekth pekth commented Sep 27, 2026 •

Copy link
Copy Markdown
Owner

OpenAI Platform and Anthropic Console users can connect separate API monitors in Settings to see organization-reported spend and tokens for today and the last 30 UTC calendar days. OpenAI also reports completion requests. Anthropic includes Messages API cache-token categories, converts decimal cents to USD, and discloses that reported costs exclude Priority Tier charges. The README explains Anthropic's individual-account restriction.

Connect provides masked key entry and tests both reporting endpoints. Entered keys are saved in MeterUsage-owned macOS Keychain items so quitting or updating the app does not forget the connection. Disconnect deletes the saved item. Storage errors remain visible and preserve the current connection. An unreadable saved key offers Restore saved connection instead of opening a new-key field. A failed save retains the entered value privately in memory for Retry saving key. Ad-hoc updates may require macOS Keychain authorization, but reuse the existing API key.

OpenAI API also appears in the side notch, showing reported 30-day spend and the existing detail card without inferring quota percentages, reset times, or pace. Quota percentages retain a fixed size when switching between cards. Organization usage stays separate from Codex/Claude subscription limits and local coding totals.

Keys are sent directly to the provider through ephemeral sessions that reject redirects. They never enter preferences, plaintext files, logs, diagnostics, or the UI as plain text. The app retains default Keychain access controls. Saved keys take precedence over launcher environment keys, which remain session-only. Demo mode and normal unit tests never access production Keychain items.

Validation at ce8d21e:

  • macOS swift build, all 391 tests, Scripts/make-app.sh, and strict code-sign verification passed for the PR source.
  • The local candidate preserving separate theme changes passed all 403 tests and the same build/signature gates. The corrected recovery candidate is prepared separately and has not replaced the running app. Theme changes are not included in this PR.
  • The restart regression failed before the fix. The old primary-action logic also failed six recovery assertions. Ten connection tests cover saved-key restoration for both providers, failed-save retry without new entry, replacement, deletion, denied reads/writes, demo isolation, and stale responses.
  • Native tests with an isolated synthetic Keychain passed cross-process restoration, locked-Keychain recovery with the same key, replacement, deletion, and saved-item retention after changing the ad-hoc binary. The changed binary required authorization; the original binary could still read the same items. Cleanup deleted the synthetic Keychain.
  • The final recovery candidate has not been tested with a real account. The existing app and saved production item were left untouched; native Keychain proof used isolated synthetic data. Prior OpenAI connectivity and stable percentage sizing have user confirmation.

Model(s): GPT-6-Astra (controller), GPT-5.6-Luna (bounded recovery edits).
Harness: T3 Code through Codex.

@pekth pekth changed the title feat: monitor OpenAI API usage and spend feat: monitor OpenAI and Anthropic API usage and spend Sep 27, 2026
@pekth pekth changed the title feat: monitor OpenAI and Anthropic API usage and spend feat: connect OpenAI and Anthropic API usage monitors Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant