-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix: support full endpoint URLs in OpenAI Compatible provider (#5212) #5214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: support full endpoint URLs in OpenAI Compatible provider (#5212) #5214
Conversation
|
i can confirm that this pr is working properly and fixes the issue originally mentioned in #5212 |
daniel-lxs
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @SannidhyaSah I left a couple of suggestions that are worth taking a look at.
Let me know what you think.
- Add HttpError interface for better type safety - Cache isFullEndpointUrl result for performance optimization - Implement smart URL detection with regex patterns for known providers - Add comprehensive tests for URL detection edge cases
- Add tests for URLs with 'embeddings' in non-endpoint contexts - Add tests for URLs with 'deployments' in non-endpoint contexts - Verify actual endpoint URLs are still correctly identified - Addresses PR review feedback for better test coverage
|
@daniel-lxs I've made the changes mentioned in the review. |
daniel-lxs
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @SannidhyaSah!
LGTM

Description
Fixes #5212
This PR resolves the 404 "Resource not found" error when using Azure OpenAI with the RooCode extension's "OpenAI Compatible" provider. The issue occurred because the OpenAI SDK automatically appends
/embeddingsto the base URL, which conflicts with Azure OpenAI's requirement for complete endpoint URLs that include the deployment name and API version.Beyond Azure OpenAI, this enhancement provides broader compatibility with various OpenAI-compatible endpoints that require specific URL structures, making the provider more flexible and robust for diverse deployment scenarios.
Changes Made
isFullEndpointUrl()method to detect when users provide complete endpoint URLs (containing/embeddingsor/deployments/)makeDirectEmbeddingRequest()for bypassing the OpenAI SDK when full URLs are provided_embedBatchWithRetries()to use either the OpenAI SDK or direct fetch based on URL typeapi-keyandAuthorizationheaders to ensure compatibility with various OpenAI-compatible servicesencoding_format: "base64"for consistent embedding handling across both pathsBroader Benefits
This solution enhances compatibility with various OpenAI-compatible endpoints beyond just Azure OpenAI:
The intelligent URL detection ensures that:
api-keyandAuthorizationheader patternsTesting
Verification of Acceptance Criteria
api-keyandAuthorizationheaders are included for broad compatibilityChecklist
Important
Fixes Azure OpenAI 404 error by supporting full endpoint URLs in
OpenAICompatibleEmbedder, enhancing compatibility with various OpenAI-compatible services.OpenAICompatibleEmbedder.isFullEndpointUrl()to detect full URLs andmakeDirectEmbeddingRequest()to handle them._embedBatchWithRetries()to choose between SDK and direct requests based on URL type.api-keyandAuthorizationheaders for broader compatibility.openai-compatible.spec.tsfor URL detection, direct requests, and error handling.This description was created by
for 49e775a. You can customize this summary. It will automatically update as commits are pushed.