Skip to content

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

feat(api): ab/a

Gergő Móriczbfc3fd549606
diff --git a/apps/api/src/controllers/v2/agent.ts b/apps/api/src/controllers/v2/agent.ts
index 3204d9314..4509eb06f 100644
--- a/apps/api/src/controllers/v2/agent.ts
+++ b/apps/api/src/controllers/v2/agent.ts
@@ -9,6 +9,7 @@ import {
import { logger as _logger } from "../../lib/logger";
import { logRequest } from "../../services/logging/log_job";
import { config } from "../../config";
+import { supabase_service } from "../../services/supabase";
export async function agentController(
req: RequestWithAuth<{}, AgentResponse, AgentRequest>,
@@ -59,6 +60,17 @@ export async function agentController(
});
}
+ const { data: freeRequest, error: freeRequestError } =
+ await supabase_service.rpc("agent_consume_free_request_if_left", {
+ i_team_id: req.auth.team_id,
+ });
+
+ if (freeRequestError) {
+ throw freeRequestError;
+ }
+
+ const isFreeRequest = !!freeRequest?.[0]?.consumed;
+
await logRequest({
id: agentId,
kind: "agent",
@@ -83,6 +95,8 @@ export async function agentController(
urls: req.body.urls,
schema: req.body.schema,
prompt: req.body.prompt,
+ apiKey: req.acuc!.api_key,
+ isFreeRequest,
}),
},
);