Skip to content

Azure OpenAI large models (gpt-5.6-luna/sol, gpt-5.4, o3) hang in OpenCode due to Responses API streaming #42147

Description

@Str0k

Bug description

When using the native Azure OpenAI provider (azure) in OpenCode, small models like gpt-5-mini work correctly, but larger models (gpt-5.6-luna, gpt-5.6-sol, gpt-5.4, o3) hang indefinitely instead of returning a response.

Steps to reproduce

  1. Configure Azure OpenAI provider with a valid resource and API key:
    $env:AZURE_RESOURCE_NAME = "<your-resource-name>"
  2. Run OpenCode with a large Azure model:
    opencode run --model azure/gpt-5.6-luna "hola, responde solo OK"
  3. The command hangs and never returns (tested up to 5 minutes).

Expected behavior

The model should respond, just like azure/gpt-5-mini does.

Actual behavior

  • azure/gpt-5-mini → ✅ works
  • azure/gpt-5.6-luna → ❌ hangs forever
  • azure/gpt-5.6-sol → ❌ hangs forever
  • azure/gpt-5.4 → ❌ hangs forever
  • azure/o3 → ❌ hangs forever

Direct API verification

I verified that the Azure OpenAI endpoints work correctly when called directly:

  • Responses API (/openai/v1/responses?api-version=v1) with gpt-5.6-luna responds quickly and streams correctly.
  • Chat Completions API (/openai/deployments/gpt-5.6-luna/chat/completions?api-version=2025-04-01-preview) also responds correctly.

So the Azure deployment and credentials are fine. The hang only happens through OpenCode.

Root cause hypothesis

OpenCode uses @ai-sdk/azure, which defaults to the Responses API when calling azure(deploymentName). The Responses API streaming path seems to hang for larger models when consumed by OpenCode, even though the same endpoint works fine with direct curl/PowerShell calls.

A likely fix would be to either:

  1. Allow users to force Chat Completions API for Azure models (e.g., via provider.azure.options.factory: "chat"), or
  2. Make @ai-sdk/azure default to chat completions for models/deployments where Responses API streaming is unreliable.

Environment

  • OS: Windows 11
  • OpenCode version: 1.17.11 (also tested on earlier versions)
  • Azure region: East US 2
  • Models deployed: gpt-5-mini, gpt-5.6-luna, gpt-5.6-sol, gpt-5.4, o3

Additional context

I also tried creating a custom provider using @ai-sdk/azure with useDeploymentBasedUrls: true, but it still calls /responses and returns 404 for api-version=2025-04-01-preview because that API version does not support the Responses API on Azure.

The only working workaround right now is to use azure/gpt-5-mini for everything, which is not ideal for complex tasks.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions