← Back to PRs

#6974: Feature/webhook gateway token

by MC-shark open 2026-02-02 07:40 View on GitHub →
gateway docker
<!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR threads a new `usageWebhookUrl` setting through gateway runtime config/state and the HTTP server, then extends the OpenAI-compatible `/v1/chat/completions` handler to (a) report real token usage in responses and (b) POST a `model.usage` webhook payload after each completion (including `gatewayToken`, usage totals, optional cost, and duration). This integrates with existing gateway auth and agent execution by extracting usage from `agentCommand` results and emitting a webhook side-effect when configured. <h3>Confidence Score: 4/5</h3> - This PR is reasonably safe to merge, with the main concern being the accuracy/semantics of the new webhook `cost` field and operational behavior of webhook delivery. - The changes are localized and mostly additive (config plumbing + usage extraction + webhook POST). The main functional risk is that the newly introduced cost computation is hard-coded and likely incorrect for many models/providers, which can mislead downstream consumers; additionally, webhook delivery lacks a timeout, which can cause resource buildup if endpoints hang. - src/gateway/openai-http.ts <!-- greptile_other_comments_section --> <sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub> <!-- /greptile_comment -->

Most Similar PRs