Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.
TypeScript aeoai-agentai-searchanswer-engine-optimizationbrand-monitoringchatgptclaudecopilotdockergeminigeogoogle-ai-overviewsgrokmcpnextjsopen-sourceperplexityseosupabasetypescript
import { NextResponse } from 'next/server';
import { authenticateMcpRequest } from '@/lib/mcp-auth';
import { getAiUsageFor } from '@/lib/mcp/account';
/** This period's AI usage for the key's organization, as the MCP tool get_ai_usage answers. */
export async function GET(req: Request) {
const auth = await authenticateMcpRequest(req);
if (auth instanceof NextResponse) return auth;
try {
const usage = await getAiUsageFor(auth);
if (usage === null) {
return NextResponse.json({ error: 'Organization not found' }, { status: 404 });
}
return NextResponse.json({ usage });
} catch (err) {
const message = err instanceof Error ? err.message : 'Failed';
return NextResponse.json({ error: message }, { status: 500 });
}
}