agentbay_budget_check
Check your project token budget status and monitor session usage to stay within allocated limits and avoid unexpected overages.
Instructions
Check the project token budget status and your session usage
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | Project ID |
Implementation Reference
- src/index.ts:917-942 (handler)The handler function for the 'agentbay_budget_check' tool. It calls the API endpoint /api/v1/projects/{projectId}/budget, checks if a monthly token budget is set (unlimited if 0), calculates usage percentage, and returns budget status including monthly budget, tokens used, remaining tokens, reset day, and session usage.
// Tool 34: Budget Check server.tool( 'agentbay_budget_check', 'Check the project token budget status and your session usage', { projectId: z.string().describe('Project ID'), }, async ({ projectId }) => { const data = await apiGet(`/api/v1/projects/${projectId}/budget`); if (data.error) return { content: [{ type: 'text' as const, text: `Error: ${data.error}` }] }; if (data.monthlyTokenBudget === 0) { return { content: [{ type: 'text' as const, text: `No token budget set for this project (unlimited).` }] }; } const pct = data.monthlyTokenBudget > 0 ? Math.round((data.tokensUsedThisMonth / data.monthlyTokenBudget) * 100) : 0; let text = `Token Budget Status:\n`; text += `Monthly budget: ${data.monthlyTokenBudget.toLocaleString()}\n`; text += `Used this month: ${data.tokensUsedThisMonth.toLocaleString()} (${pct}%)\n`; text += `Remaining: ${(data.monthlyTokenBudget - data.tokensUsedThisMonth).toLocaleString()}\n`; text += `Budget resets on day ${data.budgetResetDay} of each month\n`; if (data.sessionTokens !== undefined) { text += `\nYour session usage: ${data.sessionTokens.toLocaleString()} tokens`; } return { content: [{ type: 'text' as const, text }] }; } ); - src/index.ts:917-923 (schema)Input schema for 'agentbay_budget_check': requires a single parameter 'projectId' (string) described as 'Project ID'.
// Tool 34: Budget Check server.tool( 'agentbay_budget_check', 'Check the project token budget status and your session usage', { projectId: z.string().describe('Project ID'), }, - src/index.ts:917-919 (registration)Registration of the 'agentbay_budget_check' tool using server.tool() with name 'agentbay_budget_check' and description 'Check the project token budget status and your session usage'.
// Tool 34: Budget Check server.tool( 'agentbay_budget_check',