Description
Summary:
When using OpenCode with Azure OpenAI Cognitive Services endpoints (i.e. https://<resource>.cognitiveservices.azure.com/openai), the Responses API (/responses) requests are missing the required ?api-version=... query parameter. This causes all requests to /openai/responses to return 404, even though the same endpoint works with tools like curl.
Impact:
- Cannot use models that require the Responses API (e.g.
gpt-5.2-codex) on Azure Cognitive Services endpoints.
- Azure returns
404 Resource not found when ?api-version= is missing from the request URL.
- The same request succeeds via
curl when ?api-version=2025-04-01-preview is included manually.
Working curl example:
curl -X POST "https://<resource>.cognitiveservices.azure.com/openai/responses?api-version=2025-04-01-preview" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $AZURE_API_KEY" \
-d '{
"messages": [{"role": "user", "content": "hello"}],
"max_completion_tokens": 16384,
"model": "gpt-5.2-codex"
}'
Config attempts and results:
Attempt 1: Standard @ai-sdk/azure with resourceName
{
"provider": {
"azure": {
"npm": "@ai-sdk/azure",
"options": {
"apiKey": "<REDACTED>",
"resourceName": "<REDACTED>",
"apiVersion": "2025-04-01-preview"
},
"models": {
"gpt-5.2-codex": {
"name": "GPT 5.2 Codex",
"provider": { "npm": "@ai-sdk/azure" }
}
}
}
}
}
Result: SDK constructs URL with .openai.azure.com hostname (wrong — Cognitive Services uses .cognitiveservices.azure.com), and hits /v1/chat/completions instead of /responses. Error: The chatCompletion operation does not work with the specified model, gpt-5.2-codex.
Attempt 2: @ai-sdk/azure with baseURL override
{
"provider": {
"azure": {
"npm": "@ai-sdk/azure",
"options": {
"apiKey": "<REDACTED>",
"baseURL": "https://<resource>.cognitiveservices.azure.com/openai",
"apiVersion": "2025-04-01-preview"
},
"models": {
"gpt-5.2-codex": {
"name": "GPT 5.2 Codex",
"provider": { "npm": "@ai-sdk/azure" }
}
}
}
}
}
Result: URL hits /openai/responses (correct path) but ?api-version= query parameter is dropped. Error: 404 Resource not found.
Attempt 3: @ai-sdk/openai with api URL including query param
{
"provider": {
"azure": {
"api": "https://<resource>.cognitiveservices.azure.com/openai?api-version=2025-04-01-preview",
"npm": "@ai-sdk/openai",
"options": {
"apiKey": "<REDACTED>",
"headers": {
"api-key": "<REDACTED>"
}
},
"models": {
"gpt-5.2-codex": { "name": "GPT 5.2 Codex" }
}
}
}
}
Result: SDK appends /responses after the query string, producing a malformed URL: https://<resource>.cognitiveservices.azure.com/openai/responses?api-version=2025-04-01-preview/responses. Error: 404.
Attempt 4: @ai-sdk/openai with clean api URL (no query param)
{
"provider": {
"openai": {
"api": "https://<resource>.cognitiveservices.azure.com/openai",
"npm": "@ai-sdk/openai",
"options": {
"apiKey": "<REDACTED>",
"headers": {
"api-key": "<REDACTED>"
}
},
"models": {
"gpt-5.2-codex": { "name": "GPT 5.2 Codex" }
}
}
}
}
Result: URL hits /openai/responses (correct path) but ?api-version= is missing. Error: 404 Resource not found.
Attempt 5: Custom provider ID to bypass Azure custom loader
{
"provider": {
"azure-responses": {
"name": "Azure OpenAI",
"npm": "@ai-sdk/azure",
"options": {
"apiKey": "<REDACTED>",
"baseURL": "https://<resource>.cognitiveservices.azure.com/openai",
"apiVersion": "2025-04-01-preview"
},
"models": {
"gpt-5.2-codex": { "name": "GPT 5.2 Codex" }
}
}
}
}
Result: Same as Attempt 2 — ?api-version= is dropped when baseURL is provided. Error: 404 Resource not found.
Root cause analysis:
The issue is an architectural mismatch across three layers:
-
@ai-sdk/azure URL construction: When using resourceName, the SDK hardcodes the hostname as {resourceName}.openai.azure.com. Cognitive Services endpoints use {resourceName}.cognitiveservices.azure.com instead. When baseURL is provided to bypass this, the SDK stops appending ?api-version= to requests — this is a known limitation.
-
OpenCode's Azure custom loader (provider.ts L178-191): Correctly calls sdk.responses(modelID) by default, but has no mechanism to handle the Cognitive Services endpoint variant.
-
OpenCode's getSDK (provider.ts L1041-1117): Passes config options through to createAzure(), but there's no way for users to configure both a custom base hostname AND retain the ?api-version= query parameter behavior.
Note: The bundled @ai-sdk/azure version (2.0.91) is not obsolete — it does support the Responses API. The issue is specifically about how it constructs URLs when baseURL is overridden.
Suggested fix:
- Allow OpenCode's Azure provider to accept a full custom base URL while preserving
?api-version= injection (e.g. via a custom fetch wrapper, or by patching URL construction in the Azure loader).
- Alternatively, add explicit support for the
cognitiveservices.azure.com hostname pattern in the azure-cognitive-services custom loader.
References:
Plugins
None
OpenCode version
Latest stable (2026-02-17)
Steps to reproduce
- Deploy a model requiring the Responses API (e.g.
gpt-5.2-codex) on an Azure Cognitive Services resource
- Configure
opencode.json with provider azure, pointing at https://<resource>.cognitiveservices.azure.com/openai
- Set
"model": "azure/gpt-5.2-codex" and provide your API key
- Launch opencode and send any message
- Observe error:
404 Resource not found — the request URL is /openai/responses without ?api-version=
- Verify the same request works via curl with
?api-version=2025-04-01-preview appended
Screenshot and/or share link
Error from OpenCode logs:
AI_APICallError: Resource not found
url: "https://<resource>.cognitiveservices.azure.com/openai/responses"
statusCode: 404
responseBody: {"error":{"code":"404","message": "Resource not found"}}
Expected URL (works via curl):
https://<resource>.cognitiveservices.azure.com/openai/responses?api-version=2025-04-01-preview
Operating System
Windows 11
Terminal
Windows Terminal
Description
Summary:
When using OpenCode with Azure OpenAI Cognitive Services endpoints (i.e.
https://<resource>.cognitiveservices.azure.com/openai), the Responses API (/responses) requests are missing the required?api-version=...query parameter. This causes all requests to/openai/responsesto return 404, even though the same endpoint works with tools likecurl.Impact:
gpt-5.2-codex) on Azure Cognitive Services endpoints.404 Resource not foundwhen?api-version=is missing from the request URL.curlwhen?api-version=2025-04-01-previewis included manually.Working curl example:
Config attempts and results:
Attempt 1: Standard
@ai-sdk/azurewithresourceName{ "provider": { "azure": { "npm": "@ai-sdk/azure", "options": { "apiKey": "<REDACTED>", "resourceName": "<REDACTED>", "apiVersion": "2025-04-01-preview" }, "models": { "gpt-5.2-codex": { "name": "GPT 5.2 Codex", "provider": { "npm": "@ai-sdk/azure" } } } } } }Result: SDK constructs URL with
.openai.azure.comhostname (wrong — Cognitive Services uses.cognitiveservices.azure.com), and hits/v1/chat/completionsinstead of/responses. Error:The chatCompletion operation does not work with the specified model, gpt-5.2-codex.Attempt 2:
@ai-sdk/azurewithbaseURLoverride{ "provider": { "azure": { "npm": "@ai-sdk/azure", "options": { "apiKey": "<REDACTED>", "baseURL": "https://<resource>.cognitiveservices.azure.com/openai", "apiVersion": "2025-04-01-preview" }, "models": { "gpt-5.2-codex": { "name": "GPT 5.2 Codex", "provider": { "npm": "@ai-sdk/azure" } } } } } }Result: URL hits
/openai/responses(correct path) but?api-version=query parameter is dropped. Error:404 Resource not found.Attempt 3:
@ai-sdk/openaiwithapiURL including query param{ "provider": { "azure": { "api": "https://<resource>.cognitiveservices.azure.com/openai?api-version=2025-04-01-preview", "npm": "@ai-sdk/openai", "options": { "apiKey": "<REDACTED>", "headers": { "api-key": "<REDACTED>" } }, "models": { "gpt-5.2-codex": { "name": "GPT 5.2 Codex" } } } } }Result: SDK appends
/responsesafter the query string, producing a malformed URL:https://<resource>.cognitiveservices.azure.com/openai/responses?api-version=2025-04-01-preview/responses. Error:404.Attempt 4:
@ai-sdk/openaiwith cleanapiURL (no query param){ "provider": { "openai": { "api": "https://<resource>.cognitiveservices.azure.com/openai", "npm": "@ai-sdk/openai", "options": { "apiKey": "<REDACTED>", "headers": { "api-key": "<REDACTED>" } }, "models": { "gpt-5.2-codex": { "name": "GPT 5.2 Codex" } } } } }Result: URL hits
/openai/responses(correct path) but?api-version=is missing. Error:404 Resource not found.Attempt 5: Custom provider ID to bypass Azure custom loader
{ "provider": { "azure-responses": { "name": "Azure OpenAI", "npm": "@ai-sdk/azure", "options": { "apiKey": "<REDACTED>", "baseURL": "https://<resource>.cognitiveservices.azure.com/openai", "apiVersion": "2025-04-01-preview" }, "models": { "gpt-5.2-codex": { "name": "GPT 5.2 Codex" } } } } }Result: Same as Attempt 2 —
?api-version=is dropped whenbaseURLis provided. Error:404 Resource not found.Root cause analysis:
The issue is an architectural mismatch across three layers:
@ai-sdk/azureURL construction: When usingresourceName, the SDK hardcodes the hostname as{resourceName}.openai.azure.com. Cognitive Services endpoints use{resourceName}.cognitiveservices.azure.cominstead. WhenbaseURLis provided to bypass this, the SDK stops appending?api-version=to requests — this is a known limitation.OpenCode's Azure custom loader (
provider.tsL178-191): Correctly callssdk.responses(modelID)by default, but has no mechanism to handle the Cognitive Services endpoint variant.OpenCode's
getSDK(provider.tsL1041-1117): Passes config options through tocreateAzure(), but there's no way for users to configure both a custom base hostname AND retain the?api-version=query parameter behavior.Note: The bundled
@ai-sdk/azureversion (2.0.91) is not obsolete — it does support the Responses API. The issue is specifically about how it constructs URLs whenbaseURLis overridden.Suggested fix:
?api-version=injection (e.g. via a custom fetch wrapper, or by patching URL construction in the Azure loader).cognitiveservices.azure.comhostname pattern in theazure-cognitive-servicescustom loader.References:
Plugins
None
OpenCode version
Latest stable (2026-02-17)
Steps to reproduce
gpt-5.2-codex) on an Azure Cognitive Services resourceopencode.jsonwith providerazure, pointing athttps://<resource>.cognitiveservices.azure.com/openai"model": "azure/gpt-5.2-codex"and provide your API key404 Resource not found— the request URL is/openai/responseswithout?api-version=?api-version=2025-04-01-previewappendedScreenshot and/or share link
Error from OpenCode logs:
Expected URL (works via curl):
Operating System
Windows 11
Terminal
Windows Terminal