Skip to content

fix: normalize OPENAI_API_BASE by stripping trailing /chat/completions - #5488

Open
Sarthak816 wants to merge 1 commit into
Aider-AI:mainfrom
Sarthak816:fix/5468-cloudflare-gateway-url
Open

fix: normalize OPENAI_API_BASE by stripping trailing /chat/completions#5488
Sarthak816 wants to merge 1 commit into
Aider-AI:mainfrom
Sarthak816:fix/5468-cloudflare-gateway-url

Conversation

@Sarthak816

Copy link
Copy Markdown

Fixes #5468 - Can't connect Cloudflare gateway

When users set --openai-api-base, they commonly include the full endpoint path (/chat/completions, /openai/chat/completions, /compat/chat/completions). But litellm's openai library appends /chat/completions to the base URL, creating double-path URLs like .../chat/completions/chat/completions.

Changes in aider/main.py:

Added URL normalization for OPENAI_API_BASE — strips trailing /chat/completions so:

  • .../compat/chat/completions.../compat → litellm produces .../compat/chat/completions
  • .../openai/chat/completions.../openai → litellm produces .../openai/chat/completions
  • .../v1/chat/completions.../v1 → litellm produces .../v1/chat/completions

This fixes Cloudflare Gateway connections and any other OpenAI-compatible proxy where users include the full endpoint path.

Fixes Aider-AI#5468 - Can't connect Cloudflare gateway.

When users set --openai-api-base, they commonly include the full endpoint path
(/chat/completions, /openai/chat/completions, /compat/chat/completions).
But litellm's openai library appends /chat/completions to the base URL,
creating double-path URLs like .../chat/completions/chat/completions.

The fix strips trailing /chat/completions from OPENAI_API_BASE so URLs like:
  .../compat/chat/completions -> .../compat
  .../openai/chat/completions -> .../openai
  .../v1/chat/completions     -> .../v1

litellm then correctly appends /chat/completions to produce the right URL.
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.

Can't connect Cloudflare gateway

1 participant