Skip to content

feat(usage): split credit usage by endpoint and by day - #583

Merged
capy-ai[bot] merged 2 commits into
mainfrom
capy/split-credit-usage-by
Oct 20, 2026
Merged

capy-ai[bot] merged 2 commits into
mainfrom
capy/split-credit-usage-by

Conversation

@rakshith48

@rakshith48 rakshith48 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

firecrawl_credit_usage could only report balance and monthly totals, so an agent asked "what did I spend credits on?" had nothing to answer with. This adds two historical options and states what the tool can and can't break down.

  • byEndpoint: true splits each period by the endpoint that used the credits. Rows carry endpoint (scrape, search, crawl, map, agent, ...). It can't be combined with byApiKey or view: "current".
  • bin: "day" returns one period per UTC day instead of per calendar month. It works with the totals, byApiKey and byEndpoint.
  • The description now says the historical view covers the last 90 days and answers "what and when". It also says the tool can't attribute credits to single jobs, URLs or MCP clients, that each tool's result reports its own cost (creditsUsed, metadata.creditsUsed), and that the dashboard's Usage and Logs pages list usage per job.

Depends on firecrawl/firecrawl#5291, which adds byEndpoint and bin to GET /v2/team/credit-usage/historical. This PR is safe to deploy before it. Whenever the tool uses either option, it sends bin, and that API echoes bin back. If the echo is missing, the API ignored the new parameters, and the tool returns the monthly figures it got plus a notice saying the split or daily periods aren't available yet. It doesn't fail and doesn't pass totals off as a breakdown. Calls without the new options send exactly the requests they sent before.

The output schema adds bin and notice. Contract snapshots were regenerated with UPDATE_CONTRACT_SNAPSHOTS=1; the only change is firecrawl_credit_usage. The smoke test covers the new request shapes, the fallback against an older API, and the new argument errors. pnpm test: 198 passed.

Open in Capy


Summary by cubic

firecrawl_credit_usage now supports byEndpoint and bin: "day" so the historical view can answer what credits were spent on and when, not just monthly totals.

  • byEndpoint: true splits each period by endpoint (scrape, search, crawl, map, agent, ...). It cannot be combined with byApiKey or view: "current".
  • bin: "day" returns one period per UTC day instead of per calendar month, and works with totals, byApiKey, and byEndpoint.
  • When the API doesn't support the new options yet, the tool returns monthly figures plus a notice instead of failing or passing totals off as a breakdown.
  • The description now states the historical view covers the last 90 days and that credits can't be attributed to individual jobs, URLs, or MCP clients, and the README documents the new options.
  • Output schema adds bin and notice; contract snapshots regenerated and smoke tests cover new request shapes, the fallback, and new argument errors.

Written for commit 2aace80. Summary will update on new commits.

View guided diff Turn on auto-fix

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 11 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread tests/mcp-smoke.test.mjs
Comment thread src/tool-output.ts Outdated
Comment thread tests/contract-snapshots/tool-definitions.json Outdated
Comment thread src/usage.ts
…est daily fallback

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 10 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread README.md
@capy-ai
capy-ai Bot merged commit 3efcbce into main Oct 20, 2026
2 checks passed
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