Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

Nick: credits used added to search v2

Nicolasf5b9c388fac1
diff --git a/apps/api/src/controllers/v2/search.ts b/apps/api/src/controllers/v2/search.ts
index 158ff149d..2630363c9 100644
--- a/apps/api/src/controllers/v2/search.ts
+++ b/apps/api/src/controllers/v2/search.ts
@@ -400,7 +400,7 @@ export async function searchController(
{
job_id: jobId,
success: true,
- num_docs: credits_billed,
+ num_docs: (searchResponse.web?.length ?? 0) + (searchResponse.images?.length ?? 0) + (searchResponse.news?.length ?? 0),
docs: [searchResponse],
time_taken: timeTakenInSeconds,
team_id: req.auth.team_id,
@@ -424,6 +424,7 @@ export async function searchController(
return res.status(200).json({
success: true,
data: searchResponse,
+ creditsUsed: credits_billed,
});
} catch (error) {
if (error instanceof ScrapeJobTimeoutError) {
diff --git a/apps/api/src/controllers/v2/types.ts b/apps/api/src/controllers/v2/types.ts
index fb9240f11..86203afe0 100644
--- a/apps/api/src/controllers/v2/types.ts
+++ b/apps/api/src/controllers/v2/types.ts
@@ -1398,11 +1398,13 @@ export type SearchResponse =
success: true;
warning?: string;
data: Document[];
+ creditsUsed: number;
}
| {
success: true;
warning?: string;
data: import("../../lib/entities").SearchV2Response;
+ creditsUsed: number;
};
export type TokenUsage = {