Skip to content

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

Open
pawbana wants to merge 2 commits intomainfrom
pb/routing-fix
Open

fix: fixes doulbe v1 prefix in passthrough openai routes#174
pawbana wants to merge 2 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
fixture: fixtures.OaiChatFallthrough,
basePath: "",
requestPath: "/openai/v1/models",
expectedUpstreamPath: "/models",
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be /v1/models no?

Copy link
Contributor Author

@pawbana pawbana Feb 6, 2026

Choose a reason for hiding this comment

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

With empty base URL (no path to add as a prefix) I believe it should be /models.
This is also how I understand the OpenAI API. Base URL contains /v1 but the endpoint in API is just /models.

This is different from Anthropic where base URL doesn't contain /v1 so /v1 is part of path "in API".

Copy link
Collaborator

Choose a reason for hiding this comment

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

But the actual upstream path is /v1/models.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes but base URL contains v1 as specified for example in Codex documentation: https://developers.openai.com/codex/config-advanced#config-and-state-locations

Copy link
Collaborator

Choose a reason for hiding this comment

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

We can't rely on the base URL being set in a specific way.
Our tests should show how we relay requests to the correct upstream path whether the configured base URL includes a /v1 suffix or not.

Semantically I'd expect expectedUpstreamPath to be the full path of the upstream API, otherwise it will confuse future readers like it did me.

I only skimmed this; I'll give this a proper review on Monday.

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