From 8224bb1a01f59abb695a0c4876064a58842e333f Mon Sep 17 00:00:00 2001 From: "devin-ai-integration[bot]" <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 17 Oct 2025 16:07:37 -0400 Subject: [PATCH] Update /search endpoint pricing to 2 credits per 10 search results (#2299) Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Micah Stairs --- apps/api/src/controllers/v1/search.ts | 14 +++++++++----- apps/api/src/controllers/v2/search.ts | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/apps/api/src/controllers/v1/search.ts b/apps/api/src/controllers/v1/search.ts index b4daccab5..04ad37556 100644 --- a/apps/api/src/controllers/v1/search.ts +++ b/apps/api/src/controllers/v1/search.ts @@ -225,7 +225,8 @@ export async function searchController( res: Response, ) { // Get timing data from middleware (includes all middleware processing time) - const middlewareStartTime = (req as any).requestTiming?.startTime || new Date().getTime(); + const middlewareStartTime = + (req as any).requestTiming?.startTime || new Date().getTime(); const controllerStartTime = new Date().getTime(); const jobId = uuidv4(); @@ -313,7 +314,7 @@ export async function searchController( title: r.title, description: r.description, })) as Document[]; - credits_billed = responseData.data.length; + credits_billed = Math.ceil((responseData.data.length * 2) / 10); } else { logger.info("Scraping search results"); const scrapePromises = searchResults.map(result => @@ -452,7 +453,10 @@ export async function searchController( // Log final timing information const totalRequestTime = new Date().getTime() - middlewareStartTime; const controllerTime = new Date().getTime() - controllerStartTime; - const scrapeful = !!(req.body.scrapeOptions.formats && req.body.scrapeOptions.formats.length > 0); + const scrapeful = !!( + req.body.scrapeOptions.formats && + req.body.scrapeOptions.formats.length > 0 + ); logger.info("Request metrics", { version: "v1", mode: "search", @@ -477,9 +481,9 @@ export async function searchController( } Sentry.captureException(error); - logger.error("Unhandled error occurred in search", { + logger.error("Unhandled error occurred in search", { version: "v1", - error + error, }); return res.status(500).json({ success: false, diff --git a/apps/api/src/controllers/v2/search.ts b/apps/api/src/controllers/v2/search.ts index 7893338fd..28f83ba3a 100644 --- a/apps/api/src/controllers/v2/search.ts +++ b/apps/api/src/controllers/v2/search.ts @@ -321,8 +321,8 @@ export async function searchController( const isAsyncScraping = req.body.asyncScraping && shouldScrape; if (!shouldScrape) { - // No scraping - just count results for billing - credits_billed = totalResultsCount; + // No scraping - 2 credits per 10 search results (0.2 credits per result) + credits_billed = Math.ceil((totalResultsCount * 2) / 10); } else { // Common setup for both async and sync scraping logger.info(