Skip to content

fix(metering): register the gateway's api root, not the gateway root - #1771

Merged
pyramation merged 2 commits into
mainfrom
feat/gateway-completions-root
Aug 19, 2026
Merged

fix(metering): register the gateway's api root, not the gateway root#1771
pyramation merged 2 commits into
mainfrom
feat/gateway-completions-root

Conversation

@pyramation

Copy link
Copy Markdown
Contributor

Summary

A metered model registered the gateway root as its provider baseUrl, so every real completion went to POST <root>/chat/completions and the gateway answered 404 Cannot POST /chat/completions — it serves the OpenAI-compatible surface under /v1. Found by running a coding-agent task in-cluster against agentic-server, where a model turn died instantly with that 404.

resolveMeteredGateway now registers the api root, and the root normalizer tolerates a caller that already spelled /v1 so a configured https://gw.example.com/v1 cannot become /v1/v1:

normalizeGatewayUrl('https://gw.example.com/v1') // 'https://gw.example.com'
completionsBaseUrl('https://gw.example.com')     // 'https://gw.example.com/v1'
resolveMeteredGateway({ gatewayUrl, ... }).baseUrl // <root>/v1

Usage reporting is unchanged (<root>/v1/usage), and completionsBaseUrl is exported so a harness that builds its own provider config asks for the same route rather than re-deriving it.

Link to Devin session: https://app.devin.ai/sessions/2d292e43fd2e4f34bb84605b5aa2a250
Requested by: @pyramation

@pyramation pyramation self-assigned this Aug 19, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@pyramation
pyramation merged commit 42ff403 into main Aug 19, 2026
20 checks passed
@pyramation
pyramation deleted the feat/gateway-completions-root branch August 19, 2026 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant