Context
POST /api/v3/tools/execute/proxy (handler at apps/apollo/src/pages/api/v3/tools/execute/proxy.ts, lib at apps/apollo/src/lib/connected_accounts/executeProxy/) is currently not metered. No emitEvent / trackMeteredUsage calls in either path.
Meanwhile typed tool execution at execute_tool.ts:1107 emits TOOL_CALL_USAGE_EVENT_TYPE after every successful tool call. This creates an incentive for customers on STARTER/GROWTH plans to shift heavy traffic to proxy execute to bypass billing.
Discovered during billing v0 staging dry-run (May 18-19, 2026).
Goal
Emit a tool_calls metering event on every successful proxy execution, attributing usage to the org / project / connected account / toolkit. Premium classification (premium_tool_calls fanout in events/handlers/usage_metered/handler.ts) will happen automatically once normalized_toolkit_slug is populated — so e.g. Exa or Tavily proxy calls will correctly bill at premium rates.
Implementation sketch
- In
executeProxy/index.ts(or the API route handler afterexecuteProxyreturns Ok), emit aTOOL_CALL_USAGE_EVENT_TYPEevent mirroring the shape at execute_tool.ts:1107-1132 - Decide a
tool_slugconvention. Two options:<TOOLKIT>_PROXY_EXECUTE(e.g.GITHUB_PROXY_EXECUTE) — preserves toolkit context in the slugPROXY_EXECUTE— simpler, toolkit info still on thetoolkit_slugdimension
- Source
toolkit_slugfrom the connected account auth config — already in scope insideexecuteProxy - Verify the tool_log row gets written so
log_idis available (or add a tool_log insert if not) - Tests asserting the event fires with correct dimensions for both authed and no-auth proxy paths