From 1d9a0b965306e8a3e6faa9dbb46d88fdd6f839ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20M=C3=B3ricz?= Date: Thu, 13 Feb 2025 16:14:13 +0100 Subject: [PATCH] feat(v1/checkCredits): say "tokens" instead of "credits" if out of tokens (#1178) * feat(v1/checkCredits): say "tokens" instead of "credits" if out of tokens * feat(v1/checkCredits): better instructions for upgrade --- apps/api/src/routes/v1.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/api/src/routes/v1.ts b/apps/api/src/routes/v1.ts index 6fcb3589..cae03b28 100644 --- a/apps/api/src/routes/v1.ts +++ b/apps/api/src/routes/v1.ts @@ -48,8 +48,9 @@ function checkCreditsMiddleware( req.acuc = chunk; } if (!success) { + const currencyName = req.acuc.is_extract ? "tokens" : "credits" logger.error( - `Insufficient credits: ${JSON.stringify({ team_id: req.auth.team_id, minimum, remainingCredits })}`, + `Insufficient ${currencyName}: ${JSON.stringify({ team_id: req.auth.team_id, minimum, remainingCredits })}`, { teamId: req.auth.team_id, minimum, @@ -62,7 +63,7 @@ function checkCreditsMiddleware( return res.status(402).json({ success: false, error: - "Insufficient credits to perform this request. For more credits, you can upgrade your plan at https://firecrawl.dev/pricing or try changing the request limit to a lower value.", + "Insufficient " + currencyName + " to perform this request. For more " + currencyName + ", you can upgrade your plan at " + (currencyName === "credits" ? "https://firecrawl.dev/pricing or try changing the request limit to a lower value" : "https://www.firecrawl.dev/extract#pricing") + ".", }); } }