#6974: Feature/webhook gateway token
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
#12635: Gateway: add inbound webhook dispatch framework
by jhs129 · 2026-02-09
77.1%
#7846: feat: add agentId param to webhook agent endpoint
by Bre77 · 2026-02-03
73.4%
#8522: feat(control-ui): Add Model Requests panel for real-time API monito...
by GiantAxeWhy · 2026-02-04
73.3%
#7771: Hooks: wire lifecycle events and tests
by rabsef-bicrym · 2026-02-03
71.5%
#9909: Gateway: add HITL approvals integration
by FletcherFrimpong · 2026-02-05
71.4%
#19785: fix(gateway): support query parameter tokens for webhooks
by cfdude · 2026-02-18
70.6%
#10641: fix(gateway): deduplicate heartbeat events across instances
by saurav470 · 2026-02-06
70.4%
#8713: feat: gateway memory monitor, install linger, docs and failover
by quratus · 2026-02-04
70.4%
#13144: harden archive extraction, auth tokens, hook transforms, and queue ...
by qxlsz · 2026-02-10
70.4%
#6512: Claude/setup open claw agent f v sqk
by franelcisco · 2026-02-01
70.2%