Add Azure OpenAI Responses API support #92
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.
Add Azure OpenAI Responses API Support
Overview
This PR adds full support for Azure OpenAI's Responses API by switching from the legacy
AzureOpenAISDK client to the standardOpenAIclient with Azure's v1 endpoint format.Problem
Oracle's existing Azure integration used the
AzureOpenAISDK client, which relies on the legacy API format that doesn't support the Responses API endpoint. This caused 404/405 errors when trying to use Oracle with Azure OpenAI.Error encountered:
Root Cause
Azure OpenAI's Responses API requires:
https://resource.openai.azure.com/openai/v1/api-keyheader (notAuthorization: Bearer)The
AzureOpenAISDK client uses:https://resource.openai.azure.com/openai/deployments/{deployment}/...?api-version=2024-02-15-previewSolution
1. Switch to OpenAI Client with Custom Base URL
Replace
AzureOpenAIclient with standardOpenAIclient configured for Azure:2. Add gpt-5.2-codex Model Support
gpt-5.1-codexfor any "codex" model)3. Update API Version Documentation
Updated default API version from
2024-02-15-previewto2025-04-01-preview(current documented version for Responses API)Changes
Core Changes
src/oracle/client.ts: Switch to OpenAI client with v1 base URL and api-key headersrc/oracle/config.ts: Add gpt-5.2-codex model configurationsrc/oracle/types.ts: Add gpt-5.2-codex to KnownModelNamesrc/cli/options.ts: Fix model name parsing to support gpt-5.2-codexDocumentation & Tests
docs/openai-endpoints.md: Update API version to 2025-04-01-previewbin/oracle-cli.ts: Clarify API version requirement in help texttests/oracle/clientFactory.test.ts: Update test API versionsrc/oracle/gemini.ts: Add gpt-5.2-codex to model ID mapTesting
Tested on Azure OpenAI East US 2 with both
gpt-5.2andgpt-5.2-codexdeployments:✅ Simple queries (1.7-2.0s response time)
✅ File processing (19.9s for code review)
✅ Direct curl verification of Azure v1 Responses API endpoint
Breaking Changes
None. This is a purely additive change:
Migration
Users with Azure OpenAI simply need to ensure they have a compatible API version:
References
Closes
Fixes issues with Azure OpenAI Responses API returning 404/405 errors.
Technical Details
Azure OpenAI Responses API Support - Change Documentation
Summary
This patch adds full support for Azure OpenAI Responses API by switching from the legacy
AzureOpenAISDK client to the standardOpenAIclient with Azure's v1 endpoint format.Problem
Oracle's existing Azure support used the
AzureOpenAIclient which relies on the legacy API format:https://resource.openai.azure.com/?api-version=2024-02-15-preview)/openai/deployments/{deployment}/...However, Azure's Responses API requires the new v1 endpoint format:
https://resource.openai.azure.com/openai/v1/api-keyheader (notAuthorization: Bearer)/v1/responsesChanges Made
1. Client Initialization (
src/oracle/client.ts)Before:
After:
Why:
/openai/v1/responses, not the deployment-based pathapi-keyheader for authentication, notAuthorization: BearerOpenAIclient with custombaseURLproperly constructs the v1 paths2. Model Support - Add gpt-5.2-codex
2.1 Model Configuration (
src/oracle/config.ts)Added:
Why: Adds support for Azure's gpt-5.2-codex deployment (code-optimized variant with extended context)
2.2 Type Definitions (
src/oracle/types.ts)Added:
'gpt-5.2-codex'toKnownModelNametype union2.3 Model Mapping (
src/oracle/gemini.ts)Added:
'gpt-5.2-codex': 'gpt-5.2-codex'toMODEL_ID_MAP2.4 Model Name Parsing (
src/cli/options.ts)Before:
After:
Why: Oracle was hardcoded to map any "codex" model to
gpt-5.1-codex, breakinggpt-5.2-codexsupport3. Documentation Updates
3.1 API Version (
docs/openai-endpoints.md)Changed:
2024-02-15-preview→2025-04-01-previewWhy:
2025-04-01-preview3.2 CLI Help Text (
bin/oracle-cli.ts)Before:
After:
Why: Documents the requirement clearly in help text
3.3 Test Fixtures (
tests/oracle/clientFactory.test.ts)Changed: Test API version from
2024-08-01-previewto2025-04-01-previewWhy: Keep tests aligned with current API version
Testing Results
All tests performed on Azure East US 2 with API key
6FEH...WWWi:Test 1: Simple Query (gpt-5.2-codex)
Result: ✅ "4" (1.7s, $0.0047)
Test 2: File Review (gpt-5.2-codex)
Result: ✅ Detailed review with 756 tokens (19.9s, $0.0158)
Test 3: Simple Query (gpt-5.2)
Result: ✅ "6" (2.0s, $0.0056)
Test 4: Summarization (gpt-5.2)
Result: ✅ Summary (2.2s, $0.0105)
Verification with curl
Direct Azure Responses API call (bypassing Oracle):
Result: ✅
{"output": [{"text": "2+2 = 4."}], "status": "completed"}Confirms Azure endpoint supports Responses API with correct format.
Breaking Changes
None. This is purely additive:
Migration Path for Users
For users with Azure OpenAI:
Old setup (broken with Responses API):
New setup (works with Responses API):
The SDK will automatically construct:
https://resource.openai.azure.com/openai/v1/References
Files Changed
src/oracle/client.ts- Switch to OpenAI client with v1 base URLsrc/oracle/config.ts- Add gpt-5.2-codex model configsrc/oracle/types.ts- Add gpt-5.2-codex to KnownModelNamesrc/oracle/gemini.ts- Add gpt-5.2-codex to MODEL_ID_MAPsrc/cli/options.ts- Fix model name parsing for gpt-5.2-codexdocs/openai-endpoints.md- Update API version documentationbin/oracle-cli.ts- Update CLI help texttests/oracle/clientFactory.test.ts- Update test API versionCommit Message
Next Steps
git push origin fix/azure-responses-api-support