Skip to content

fix(model-connections): use OpenAI-compatible base URL verbatim and deprecate raw provider - #1641

Merged
MODSetter merged 14 commits into
MODSetter:devfrom
AnishSarkar22:fix/openai-compatible-models
Jul 26, 2026
Merged

fix(model-connections): use OpenAI-compatible base URL verbatim and deprecate raw provider#1641
MODSetter merged 14 commits into
MODSetter:devfrom
AnishSarkar22:fix/openai-compatible-models

Conversation

@AnishSarkar22

@AnishSarkar22 AnishSarkar22 commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

Description

  • Use the OpenAI-compatible base URL exactly as entered across chat, model discovery, and connection verification; SurfSense no longer auto-appends /v1, matching how LiteLLM and the OpenAI SDK treat api_base.
  • Remove the ensure_v1 helper entirely; to_litellm now only special-cases Anthropic (strips a trailing /v1 so LiteLLM's native handler doesn't produce /v1/v1/messages) and passes every other provider's base URL through verbatim.
  • Apply verbatim handling to all OpenAI-compatible discovery, including OpenRouter and Requesty; their default base URLs already include /v1, so real-world behavior is unchanged, but the path is no longer forced.
  • Query {base_url}/models exactly as entered for discovery and verification.
  • Deprecate openai_compatible_raw: hidden from the provider catalog so it can no longer be added, while kept in the registry so pre-existing connections still resolve and work; the merged openai_compatible (now verbatim) covers the former raw use case.
  • Simplify the connect form to a single OpenAI-compatible option with a hint that the base URL is used as-is (include /v1), dropping the separate raw-endpoint guidance and the endpoint preview.
  • Update unit tests: drop the ensure_v1 assertions and add coverage that a bare host is not rewritten with /v1 and that custom paths (e.g. /api/v3) are preserved.
  • Correct the LM Studio and other-local-servers docs to state the base URL is used verbatim (include /v1) and lead 404 troubleshooting with a check that the base URL contains /v1.
  • No database migration or backfill required; the only affected case is pre-existing bare-host openai_compatible connections, which fail loudly and are fixed by adding /v1 to the URL.

Motivation and Context

FIX #

Screenshots

API Changes

  • This PR includes API changes

Change Type

  • Bug fix
  • New feature
  • Performance improvement
  • Refactoring
  • Documentation
  • Dependency/Build system
  • Breaking change
  • Other (specify):

Testing Performed

  • Tested locally
  • Manual/QA verification

Checklist

  • Follows project coding standards and conventions
  • Documentation updated as needed
  • Dependencies updated as needed
  • No lint/build errors or new warnings
  • All relevant tests are passing

High-level PR Summary

This PR changes how OpenAI-compatible base URLs are handled throughout the system. Previously, the system would automatically append /v1 to base URLs; now the URL is used exactly as entered by the user. The openai_compatible_raw provider is deprecated (hidden from the catalog but kept for backward compatibility), as the main openai_compatible provider now handles both standard and custom paths. Special handling for Anthropic (stripping version suffixes) and fixed endpoints like OpenRouter/Requesty (which still append /v1) are preserved. The UI, documentation, and tests are updated to reflect that users must include /v1 in their base URLs when needed.

⏱️ Estimated Review Time: 5-15 minutes

💡 Review Order Suggestion
Order File Path
1 surfsense_backend/app/services/provider_registry.py
2 surfsense_backend/app/services/model_resolver.py
3 surfsense_backend/app/services/model_connection_service.py
4 surfsense_backend/tests/unit/services/test_model_connections.py
5 surfsense_backend/app/routes/model_connections_routes.py
6 surfsense_web/components/settings/model-connections/default-connect-form.tsx
7 surfsense_web/content/docs/local-models/lm-studio.mdx
8 surfsense_web/content/docs/local-models/other-local-servers.mdx

Need help? Join our Discord

@vercel

vercel Bot commented Jul 26, 2026

Copy link
Copy Markdown

@AnishSarkar22 is attempting to deploy a commit to the Rohan Verma's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c88939a7-9315-4d35-aad6-30e361434565

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@MODSetter
MODSetter merged commit a327ae8 into MODSetter:dev Jul 26, 2026
6 of 11 checks passed
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.

2 participants