docs(credits): web search 5→1 credit + auto top-up opt-out contract#270
docs(credits): web search 5→1 credit + auto top-up opt-out contract#270sweetmantech wants to merge 2 commits into
Conversation
…p opt-out contract
Web-search research now costs 1 credit per call (provider cost is $0.005/request
flat). Adds GET/PATCH /api/accounts/{id}/auto-recharge to the accounts OpenAPI:
the opt-out lives on the account's Stripe customer record, disabling never
removes the saved card, and opted-out accounts fail closed to the existing
402 + checkoutUrl manual-checkout path.
Contract for recoupable/chat#1861 (merge first: docs → api → chat).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
📝 WalkthroughWalkthroughAdds a new auto top-up (auto-recharge) API surface with GET/PATCH OpenAPI endpoints and schemas, corresponding MDX reference pages wired into docs navigation, and updates credits.mdx to document opt-out behavior for the automatic top-up charge and a revised per-call credit cost for the research web endpoint. ChangesAuto Top-Up Feature Docs
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
credits.mdx (1)
118-124: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winDecision tree doesn't cover the opted-out case.
Line 118 adds "and the account hasn't opted out" as a precondition for the silent charge, but the decision tree at lines 122–124 doesn't mention opted-out accounts. An opted-out account with a valid saved card and a small shortfall doesn't match any of the three listed branches, yet should fall through to HTTP 402. Consider adding the opted-out condition to step 3 or adding a new step.
💚 Proposed update to the decision tree
3. **No card on file, *or* opted out of auto top-up, *or* Stripe declined the card, *or* request needs more than 500 credits?** → Request returns **HTTP 402** with a recovery URL (see below).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@credits.mdx` around lines 118 - 124, The decision tree in credits.mdx omits the opted-out path, leaving the behavior unclear for accounts that have a saved card but have opted out of silent top-ups. Update the decision tree so the branching in the section with the credit gate matches the precondition described above, using the same “opted out” concept and the existing “Opting out” reference. Either fold opted-out accounts into the HTTP 402 branch or add a separate branch before the off-session charge step so the flow clearly shows they do not get auto-charged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@credits.mdx`:
- Around line 118-124: The decision tree in credits.mdx omits the opted-out
path, leaving the behavior unclear for accounts that have a saved card but have
opted out of silent top-ups. Update the decision tree so the branching in the
section with the credit gate matches the precondition described above, using the
same “opted out” concept and the existing “Opting out” reference. Either fold
opted-out accounts into the HTTP 402 branch or add a separate branch before the
off-session charge step so the flow clearly shows they do not get auto-charged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f0d2902b-6d52-4693-b317-8eb820441f18
📒 Files selected for processing (5)
api-reference/accounts/auto-recharge-get.mdxapi-reference/accounts/auto-recharge-update.mdxapi-reference/openapi/accounts.jsoncredits.mdxdocs.json
There was a problem hiding this comment.
All reported issues were addressed across 5 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
Summary
POST /api/research/webfrom 5 credits to 1 credit per call in the billed-endpoints table (provider cost is $0.005/request flat; the 5-credit fee overpriced generic web search ~10x).GET+PATCH /api/accounts/{id}/auto-recharge(OpenAPI blocks, two frontmatter-only reference pages, Billing nav entries), plus an Opting out section incredits.mdxand the opted-out branch in the auto top-up decision tree.Contract highlights
enabled: trueis the default for every account; the setting lives on the account's Stripe customer record and is read live.checkoutUrlshape — no new error envelope.Merge order
This is the contract PR for recoupable/chat#1861: docs (this) → api → chat. The api PR implements exactly this spec.
OpenAPI diff is purely additive (206 insertions, 0 deletions); both
docs.jsonandaccounts.jsonre-validated as parseable.🤖 Generated with Claude Code
Summary by cubic
Repriced
POST /api/research/webfrom 5 to 1 credit and added an auto top-up opt-out API so accounts can disable off-session charges without removing their saved card.New Features
GET/PATCH /api/accounts/{id}/auto-recharge(defaultenabled: true, stored on the account’s Stripe customer). Whenenabled: false, requests that exceed balance return 402 withcheckoutUrl; no new error shape. Docs include new reference pages and an “Opting out” section with the decision tree update.POST /api/research/webnow costs 1 credit per call. Billed-endpoints table updated.Bug Fixes
$ACCOUNT_ID.Written for commit 940211b. Summary will update on new commits.
Summary by CodeRabbit
New Features
Bug Fixes
Documentation