Skip to content

fix: fixes double v1 prefix in passthrough openai routes#174

Merged
pawbana merged 4 commits intomainfrom
pb/routing-fix
Feb 9, 2026
Merged

fix: fixes double v1 prefix in passthrough openai routes#174
pawbana merged 4 commits intomainfrom
pb/routing-fix

Conversation

@pawbana
Copy link
Contributor

@pawbana pawbana commented Feb 6, 2026

fix: fixes doulbe v1 prefix in passthrough openai routes

Bug introduced in #159

With default OpenAI base url https://api.openai.com/v1/
pass though routes have v1 prefix added 2 times (from
base url path + pass though route prefix) resulting
in requests being forwarded to https://api.openai.com/v1/v1/
This PR fixes the issue.

Fixes: #176

With default OpenAI base url "https://api.openai.com/v1/"
passthough routes have `v1` prefix added 2 times resulting
in requests being forwarded to "https://api.openai.com/v1/v1/"
This PR fixes the issue.
Copy link
Contributor Author

pawbana commented Feb 6, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@pawbana pawbana marked this pull request as ready for review February 6, 2026 13:25
@dannykopping dannykopping changed the title fix: fixes doulbe v1 prefix in passthrough openai routes fix: fixes double v1 prefix in passthrough openai routes Feb 9, 2026

func (p *OpenAI) RoutePrefix() string {
// Route prefix includes version to match default OpenAI base URL.
// More detailed explanation: https://github.com/coder/aibridge/pull/174#discussion_r2782320152
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: deep linking doesn't really work once threads are resolved. I'd prefer you copied the reasoning inline.

//
// When request is bridged, interceptor created based on route processes the request.
// When request is passed through the {host} + {aibridge root} + {provider prefix} URL part
// is replaced by provider's base URL and request is forwarded.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// is replaced by provider's base URL and request is forwarded.
// is replaced by provider's BaseURL() and request is forwarded.

//
// - OpenAI chat completions
// AI Bridge base URL (set in Codex): "https://host.coder.com/api/v2/aibridge/openai/v1"
// Upstream base URl (set in coder config): http://api.openai.com/v1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// Upstream base URl (set in coder config): http://api.openai.com/v1
// Upstream base URL (set in coder config): http://api.openai.com/v1

Copy link
Contributor Author

pawbana commented Feb 9, 2026

Merge activity

  • Feb 9, 4:18 PM UTC: A user started a stack merge that includes this pull request via Graphite.

@pawbana pawbana merged commit dd80481 into main Feb 9, 2026
5 checks passed
pawbana added a commit to coder/coder that referenced this pull request Feb 10, 2026
Updates AI Bridge library to apply fix:
coder/aibridge#174
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.

bug: OpenAI pass though routes are forwarded with double /v1 prefix

2 participants