Skip to content

Phase 0: remove hardcoded API key/proxy, restore BYO-key auth, model-aware cost estimates - #14

Open
zackkitzmiller wants to merge 2 commits into
mainfrom
fix/phase0-remove-hardcoded-key
Open

Phase 0: remove hardcoded API key/proxy, restore BYO-key auth, model-aware cost estimates#14
zackkitzmiller wants to merge 2 commits into
mainfrom
fix/phase0-remove-hardcoded-key

Conversation

@zackkitzmiller

Copy link
Copy Markdown
Member

Why

src/ai/claude.rs shipped with a real Anthropic API key hardcoded in source and forced every request to http://localhost:8787, discarding the caller's key entirely. The AI pipeline could not work anywhere without that local proxy, and the key is exposed in git history and the published crates.io 0.1.3 release.

Changes

  • Remove the hardcoded key and localhost base URL. ClaudeProvider::new honors the passed key; default base URL is https://api.anthropic.com; with_base_url now works in release builds, so --api-base-url / ANTHROPIC_BASE_URL / [ai].base_url are honored.
  • Wire real auth in main.rs: key resolved from CLI flag → env → config.toml via the existing config.api_key() (which already has a friendly error). --no-ai / --dupes-only / --undo need no key.
  • Model-aware cost estimation: cost.rs prices by model family (haiku $1/$5, sonnet $3/$15, opus $5/$25, fable $10/$50 per MTok) instead of hardcoded Sonnet rates; PipelineConfig carries the model id.
  • Default model → claude-opus-5 (drop-in successor at the same price as opus-4-8).
  • README: real key-setup docs; removed the nonexistent --describe-only flag.

⚠️ Required follow-ups (manual)

  1. Rotate the leaked Anthropic API key immediately — it is in git history and in the crates.io 0.1.3 tarball.
  2. Yank 0.1.3 on crates.io (cargo yank --version 0.1.3) and publish 0.1.4 from this branch.

Test plan

  • cargo test — 334 passed (incl. new pricing-by-model tests)
  • cargo clippy --all-targets — clean
  • grep confirms no trace of the key or localhost:8787 in the tree

…are cost estimates

- ClaudeProvider::new now uses the caller's API key and defaults to
  https://api.anthropic.com; with_base_url works outside tests so
  --api-base-url / ANTHROPIC_BASE_URL / config base_url are honored
- main.rs resolves the key via config (env/CLI/config.toml) and fails
  with a clear message when AI analysis needs one; --no-ai and
  --dupes-only run without a key
- cost.rs prices by configured model family (haiku/sonnet/opus/fable)
  instead of hardcoded Sonnet rates; PipelineConfig carries the model
- default model bumped to claude-opus-5 (drop-in at opus-4-8 pricing)
- README: document real key setup, drop nonexistent --describe-only
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