Skip to content

feat: add management endpoint forwarding to GenericRouter (closes #276)#3631

Open
dungnthe130669 wants to merge 1 commit into
maximhq:devfrom
dungnthe130669:feat/management-endpoints-276
Open

feat: add management endpoint forwarding to GenericRouter (closes #276)#3631
dungnthe130669 wants to merge 1 commit into
maximhq:devfrom
dungnthe130669:feat/management-endpoints-276

Conversation

@dungnthe130669
Copy link
Copy Markdown

Summary

Closes #276

Bifrost currently only supports operational POST endpoints (completions, embeddings, etc.) but lacks management GET endpoints needed for a complete drop-in replacement.

This PR adds management endpoint forwarding to GenericRouter using the existing Passthrough infrastructure — no new HTTP client needed.

Changes

router.go

  • Add ManagementConfig struct with Provider and StripPrefix fields
  • Add ManagementConfig field to RouteConfig
  • Add createManagementHandler() — strips prefix, builds BifrostPassthroughRequest, proxies via handlePassthroughNonStream
  • Short-circuit management routes in RegisterRoutes before normal Bifrost pipeline validation

openai.go

  • GET /openai/v1/models/{model_id} — retrieve model details
  • DELETE /openai/v1/models/{model_id} — delete fine-tuned model
  • GET /openai/v1/organizations — list organizations
  • GET /openai/v1/usage — usage stats

anthropic.go

  • GET /anthropic/v1/models/{model_id} — retrieve model details
  • GET /anthropic/v1/usage — usage stats

genai.go

  • Stub added (existing routes already cover model listing for GenAI)

How it works

createManagementHandler reuses the existing handlePassthroughNonStream path:

  1. Strip integration prefix (e.g. /openai) from incoming path
  2. Forward original query params
  3. Pass safe headers (excluding hop-by-hop)
  4. Build BifrostPassthroughRequest with provider + auth from configured keys
  5. Return provider response directly to caller

Testing

The repo requires go 1.26.1 + go.work workspace setup. Logic was verified to have zero new compilation errors beyond pre-existing workspace setup issues (confirmed via git stash baseline comparison).

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 20, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 20, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e3871770-e0d3-44de-a159-fdaa6b8f2432

📥 Commits

Reviewing files that changed from the base of the PR and between f4834dc and f9b5f98.

📒 Files selected for processing (4)
  • transports/bifrost-http/integrations/anthropic.go
  • transports/bifrost-http/integrations/genai.go
  • transports/bifrost-http/integrations/openai.go
  • transports/bifrost-http/integrations/router.go

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Anthropic: Management endpoints added for usage and model info passthrough under the Anthropic integration.
    • OpenAI: Management endpoints added for organizations, usage, model info, and model deletion passthrough under the OpenAI integration.
    • GenAI: Foundation added for future management passthrough endpoints (currently inactive).
    • Router: Support added for registering management/admin passthrough handlers so integrations can expose management routes.

Walkthrough

Adds ManagementConfig-based passthrough routing and provider-specific management route factories; RegisterRoutes registers management handlers, createManagementHandler builds filtered passthrough requests, and OpenAI, Anthropic, and GenAI routers append their management routes.

Changes

Management Endpoints Support

Layer / File(s) Summary
Management routing infrastructure
transports/bifrost-http/integrations/router.go
Adds ManagementConfig type and RouteConfig.ManagementConfig field; RegisterRoutes detects management routes and registers passthrough handlers (GET/POST/DELETE); createManagementHandler filters headers, strips prefix, resolves provider selection, and calls passthrough proxy.
OpenAI management routes
transports/bifrost-http/integrations/openai.go
Adds CreateOpenAIManagementRouteConfigs(pathPrefix string) producing routes for /v1/organizations, /v1/usage, GET /v1/models/{model_id}, and DELETE /v1/models/{model_id}, and appends them during router init.
Anthropic management routes
transports/bifrost-http/integrations/anthropic.go
Adds CreateAnthropicManagementRouteConfigs(pathPrefix string) producing routes for /v1/usage and GET /v1/models/{model_id}, and appends them during router init.
GenAI management placeholder
transports/bifrost-http/integrations/genai.go
Adds CreateGenAIManagementRouteConfigs(pathPrefix string) as a placeholder returning nil and appends its result during router init.

Sequence Diagram

sequenceDiagram
  participant Client
  participant RegisterRoutes
  participant createManagementHandler
  participant handlePassthroughNonStream
  participant UpstreamProvider
  Client->>RegisterRoutes: HTTP request to management route
  RegisterRoutes->>createManagementHandler: detected ManagementConfig
  createManagementHandler->>createManagementHandler: filter headers, strip prefix, resolve provider
  createManagementHandler->>handlePassthroughNonStream: BifrostPassthroughRequest
  handlePassthroughNonStream->>UpstreamProvider: forward with provider auth
  UpstreamProvider-->>handlePassthroughNonStream: response
  handlePassthroughNonStream-->>Client: proxied response
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐇 I nibble headers, trim the trail,

Keys picked softly, I wag my tail.
Routes now bounce models and usage through,
A tiny proxy hop — hello, anew.
🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Linked Issues check ❓ Inconclusive The PR fulfills core objectives from issue #276: management endpoint forwarding for OpenAI and Anthropic, plus GenAI stub. However, some list endpoints are missing compared to the issue requirements. Verify if GET /v1/models list endpoints are intentionally deferred or if they should be included. The PR mentions they are handled elsewhere for some providers but clarification is needed.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: adding management endpoint forwarding to GenericRouter and closes the referenced issue #276.
Description check ✅ Passed The description covers summary, detailed changes, testing approach, and how it works, though it lacks explicit sections for some template items like type of change, affected areas, screenshots, and security considerations.
Out of Scope Changes check ✅ Passed All code changes directly support the management endpoint forwarding objective. The additions to router.go, openai.go, anthropic.go, and genai.go are all scope-aligned without extraneous modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]
coderabbitai Bot previously approved these changes May 20, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 20, 2026

Confidence Score: 5/5

The change is a safe, additive layer that reuses the well-tested passthrough infrastructure; no existing routes are modified or removed.

The implementation correctly delegates to handlePassthroughNonStream, which owns context cancellation via its own defer cancel(). Header filtering follows the same allow/drop rules already used in handlePassthrough. New route paths (/v1/models/{model_id}, /v1/usage, /v1/organizations) do not overlap with any pre-existing registered routes. The GenAI stub returning nil is a valid no-op append in Go and is clearly documented.

No files require special attention.

Important Files Changed

Filename Overview
transports/bifrost-http/integrations/router.go Adds ManagementConfig struct, createManagementHandler, and short-circuit registration in RegisterRoutes; correctly reuses handlePassthroughNonStream and follows existing patterns for header filtering and context management.
transports/bifrost-http/integrations/openai.go Adds CreateOpenAIManagementRouteConfigs with GET/DELETE for /v1/models/{model_id}, GET /v1/organizations, and GET /v1/usage; no conflicts with existing list-models routes.
transports/bifrost-http/integrations/anthropic.go Adds CreateAnthropicManagementRouteConfigs for GET /v1/usage and GET /v1/models/{model_id}; no overlap with existing CreateAnthropicListModelsRouteConfigs which only covers /v1/models (no path param).
transports/bifrost-http/integrations/genai.go Adds CreateGenAIManagementRouteConfigs stub that returns nil; called in NewGenAIRouter as a no-op append, kept for extensibility per inline comment.

Reviews (4): Last reviewed commit: "feat: add management endpoint forwarding..." | Re-trigger Greptile

Comment thread transports/bifrost-http/integrations/router.go
Comment thread transports/bifrost-http/integrations/router.go Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@transports/bifrost-http/integrations/openai.go`:
- Around line 2923-2929: The new route block adding a management GET for
pathPrefix + "/v1/models" duplicates the existing
CreateOpenAIListModelsRouteConfigs registration and causes ambiguous routing;
remove this duplicate RouteConfig (the block with Type: RouteConfigTypeOpenAI,
Path: pathPrefix + "/v1/models", Method: "GET", ManagementConfig: mgmtCfg) or
change it to a distinct management-only path, and instead rely on
CreateOpenAIListModelsRouteConfigs for the public /v1/models handler so there is
only one registration for that method/path.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3584ad73-da8c-48e0-b139-e1e5fa282ebe

📥 Commits

Reviewing files that changed from the base of the PR and between 55fe1f7 and 3852b00.

📒 Files selected for processing (2)
  • transports/bifrost-http/integrations/openai.go
  • transports/bifrost-http/integrations/router.go

Comment thread transports/bifrost-http/integrations/openai.go Outdated
…imhq#276)

- Add ManagementConfig struct with Provider and StripPrefix fields
- Add createManagementHandler() using existing Passthrough infrastructure
- Register OpenAI management routes: GET/DELETE /v1/models/{model_id}, GET /v1/usage, GET /v1/organizations
- Register Anthropic management routes: GET /v1/models/{model_id}, GET /v1/usage
- Add empty GenAI stub (existing routes cover model listing)
- No duplicate routes: GET /v1/models (list) stays with CreateOpenAIListModelsRouteConfigs

Closes maximhq#276
@dungnthe130669 dungnthe130669 force-pushed the feat/management-endpoints-276 branch from d91c0e2 to f9b5f98 Compare May 20, 2026 14:17
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.

[Feature]: Add management endpoints support for complete drop-in replacement compatibility across all integrations

2 participants