feat: Add API version support for Azure OpenAI in codebase indexing #5266
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes issue #5212 by adding support for the required
api-versionquery parameter when using Azure OpenAI with the "OpenAI Compatible" provider in codebase indexing.Problem
When using Azure OpenAI embedding models through the "OpenAI Compatible" provider, users consistently receive 404 errors because the extension doesn't include the mandatory
api-versionquery parameter that Azure OpenAI API requires.Solution
apiVersionparameter in the OpenAI Compatible provider configurationOpenAICompatibleEmbedderto intelligently append theapi-versionquery parameter to the base URLTechnical Details
URL Construction Logic
The embedder now handles both scenarios:
https://example.openai.azure.com/openai/deployments/model→https://example.openai.azure.com/openai/deployments/model?api-version=2023-05-15https://example.com/api?key=value→https://example.com/api?key=value&api-version=2023-05-15Files Modified
packages/types/src/codebase-index.ts- Added schema validationsrc/services/code-index/interfaces/config.ts- Updated interfacessrc/services/code-index/config-manager.ts- Added config managementsrc/services/code-index/embedders/openai-compatible.ts- Core URL construction logicsrc/services/code-index/service-factory.ts- Updated service instantiationwebview-ui/src/components/settings/CodeIndexSettings.tsx- Added UI fieldwebview-ui/src/i18n/locales/en/settings.json- Added translationssrc/services/code-index/embedders/__tests__/openai-compatible.spec.ts- Added testsTesting
✅ All existing tests pass
✅ New test cases cover API version functionality
✅ Type checking passes across all packages
✅ Linting passes with no warnings
Manual Testing Instructions
https://your-resource.openai.azure.com/openai/deployments/your-model)2023-05-15) in the new "API Version" fieldBackward Compatibility
✅ The
apiVersionfield is optional, so existing configurations continue to work✅ No breaking changes to existing APIs or interfaces
✅ Graceful handling when API version is not provided
Fixes #5212
Important
Adds optional
apiVersionsupport for Azure OpenAI in OpenAI Compatible provider, updating URL logic, UI, and tests.apiVersionparameter to OpenAI Compatible provider configuration.OpenAICompatibleEmbedderto appendapi-versionquery parameter to URLs.CodeIndexSettings.tsxto include "API Version" input field.apiVersion.openai-compatible.spec.tsto coverapiVersionfunctionality.This description was created by
for 5ab3ae8. You can customize this summary. It will automatically update as commits are pushed.