check_balance
Check remaining Pollinations API credits for paid models to monitor usage and manage access to image, video, and audio generation tools.
Instructions
Check your Pollinations API balance (pollen). Shows remaining credits for paid models.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools.ts:328-375 (handler)The handler function that performs the HTTP request to Pollinations API to check the account balance.
export async function handleCheckBalance() { if (!API_KEY) { return { content: [ { type: "text" as const, text: "No POLLINATIONS_API_KEY set. Balance check requires an API key.\nFree models (flux, turbo) work without a key.", }, ], }; } try { const res = await fetch("https://gen.pollinations.ai/account/balance", { headers: { Authorization: `Bearer ${API_KEY}` }, }); if (!res.ok) { return { content: [{ type: "text" as const, text: `Balance check failed: HTTP ${res.status}` }], isError: true, }; } const data = await res.json() as { balance?: number; pollen?: number }; const balance = data.balance ?? data.pollen ?? 0; return { content: [ { type: "text" as const, text: [ `Pollinations balance: ${balance} pollen`, `API key: ${API_KEY.slice(0, 6)}...${API_KEY.slice(-4)}`, "", "Free models (flux, turbo, wan2.6) use 0 pollen.", "Paid models: gptimage ~5, imagen-4 ~3, grok-imagine ~3, seedance-pro ~20 pollen/gen.", ].join("\n"), }, ], }; } catch (err) { return { content: [{ type: "text" as const, text: `Balance check error: ${err}` }], isError: true, }; } } - src/tools.ts:89-89 (schema)The input schema definition for the check_balance tool.
export const checkBalanceSchema = z.object({}); - src/index.ts:71-76 (registration)The registration of the check_balance tool within the MCP server.
server.tool( "check_balance", "Check your Pollinations API balance (pollen). Shows remaining credits for paid models.", checkBalanceSchema.shape, async () => handleCheckBalance() );