Skip to content

Normalize module client base_url trailing slash#2990

Open
LittleChenLiya wants to merge 1 commit intoopenai:mainfrom
LittleChenLiya:fix-module-client-base-url-trailing-slash
Open

Normalize module client base_url trailing slash#2990
LittleChenLiya wants to merge 1 commit intoopenai:mainfrom
LittleChenLiya:fix-module-client-base-url-trailing-slash

Conversation

@LittleChenLiya
Copy link

Summary

Fix inconsistent base_url normalization between the module-level client and instantiated clients.

When openai.base_url is set without a trailing slash, _ModuleClient.base_url returned the raw URL, while OpenAI(base_url=...) normalized it with a trailing slash. This could lead to malformed request URLs in module-level usage.

Changes

  • normalize _ModuleClient.base_url using the same trailing-slash enforcement as instantiated clients
  • add a regression test for module-level base_url with a custom path and no trailing slash
  • keep the module-level openai.base_url value unchanged as user input, while ensuring the resolved client URL is normalized

Testing

  • python -m pytest tests/test_module_client.py -n 0
  • python -m pytest tests/test_client.py -k "base_url" -n 0

Closes #1373

@LittleChenLiya LittleChenLiya requested a review from a team as a code owner March 19, 2026 06:32
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.

Inconsistent base_url behavior with module client and OpenAIClient

1 participant