Skip to content

Bug and fix: LiteLLM Connection Fails with Trailing Slash in Base URL #4273

@kcwhite

Description

@kcwhite

App Version

3.19.3

API Provider

LiteLLM

Model Used

bedrock-us.anthropic.claude-3-7-sonnet-20250219-v1:0

🔁 Steps to Reproduce

Description

When configuring Roo Code to connect to a LiteLLM server with a base URL that includes a trailing slash, the connection fails because the API endpoint is constructed incorrectly, resulting in a double slash in the URL path.

Steps to Reproduce

  1. Open Roo Code
  2. Click on the Settings icon (gear) in the Roo Code panel header
  3. Select "Providers" from the settings menu
  4. Click "API Provider"
  5. Select "LiteLLM" from the provider dropdown
  6. In the "Base URL" field, enter a URL with a trailing slash (e.g., "http://localhost:4000/")
  7. Enter your API key in the "API Key" field
  8. Click "Save"
  9. Click "Refresh Models"
  10. Observe the error "Failed to fetch LiteLLM models: 404 Not Found. Check base URL and API key."

Expected Behavior

Roo Code should successfully connect to the LiteLLM server regardless of whether the base URL contains a trailing slash.

Actual Behavior

The connection fails because the API endpoint is constructed as "http://localhost:4000//v1/model/info" (note the double slash), which is not a valid URL path.

Additional Information

This issue occurs because the base URL is directly concatenated with the endpoint path without checking for or handling trailing slashes, resulting in malformed URLs when users include a trailing slash in their configuration.

💥 Outcome Summary

Expected to connect to corporate LiteLLM gateway, but got a 404 Not Found Error instead. Credentials were valid.

📄 Relevant Logs or Errors (Optional)

Failed to fetch LiteLLM models: 404 Not Found. Check base URL and API key.

Metadata

Metadata

Assignees

Labels

Issue - In ProgressSomeone is actively working on this. Should link to a PR soon.bugSomething isn't working

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions