Skip to content

OpenRouter returns "OpenAI is temporarily unavailable" error #26469

Closed

Description

@DanielleMaywood

I tried setting up glm-5.2 as a model via the openrouter provider but was unable to get it to work.

Steps to reproduce

  1. Launch coder with CODER_AI_GATEWAY_DUMP_DIR=/tmp/aibridge-dumps
  2. Configure an OpenRouter provider
  3. Configure z-ai/glm-5.2 as a model with the OpenRouter provider
  4. Enable experimental chat debug logging for deployment
  5. Enable experimental chat debug logging for user
  6. Attempt to send a message via Coder Agents
  7. Observe a somewhat useless error message from Coder Agents
  8. Click into "Debug" tab
  9. Click into one of the failed steps
  10. Observe error bad gateway: unknown stream error: unexpected end of JSON input
  11. Also observe the dump from AI Gateway

(some fields removed for brevity)

HTTP/2.0 200 OK
Content-Type: text/event-stream

: OPENROUTER PROCESSING

Possible Root cause

Based on the AI Gateway dump, we can assume the follow steps occur:

Impact

Any provider that emits SSE comment-only events (comment lines followed by blank lines with no data: field) will trigger this bug.

Activity

  1. linear-code commented on Jun 17, 2026

    @linear-code
  2. added
    community
    on Jun 18, 2026
  3. raphaelbahat commented on Jun 18, 2026

    @raphaelbahat

    I'm also experiencing the same issue, and it's important to note that this bug seems to effect more than just the OpenRouter GLM-5.2 model; The same issue occurred when I tried OpenRouter Gemini 3.5 Flash, some Qwen models, etc.

  4. raphaelbahat commented on Jun 23, 2026

    @raphaelbahat

    Any updates?

  5. dannykopping commented on Jun 23, 2026

    @dannykopping
    Collaborator

    @raphaelbahat apologies for the radio silence. We will be looking into this soon!

  6. kasyap1234 commented on Jun 24, 2026

    @kasyap1234

    @dannykopping My guess is that the bug is in the github.com/openai/openai-go/v3 SDK, but specifically in a fork maintained at github.com/kylecarbs/openai-go/v3, it is being used by a replace directive in go.mod .
    The problematic code is in packages/ssestream/ssestream.go:72-78 of that fork. The decoder's Next() method dispatches an event for every empty line it encounters, even when no data: fields were collected. This means comment-only SSE blocks (like : OPENROUTER PROCESSING\n\n) produce empty events that fail JSON unmarshaling.
    The Anthropic SDK (github.com/coder/anthropic-sdk-go) has an identical decoder implementation but is less likely to be hit by this bug in practice since it uses an explicit switch on known event types rather than attempting to unmarshal everything.

  7. dannykopping commented on Jun 24, 2026

    @dannykopping
    Collaborator

    I believe you're right @kasyap1234

  8. kasyap1234 commented on Jun 24, 2026

    @kasyap1234

    @dannykopping I would like to fix this issue , if that is fine ?

  9. dannykopping commented on Jun 24, 2026

    @dannykopping
    Collaborator

    We'd appreciate that @kasyap1234! We have an engineer scheduled to work on this from next week, but if you're able to look at it sooner we'd welcome the contribution.

  10. raphaelbahat commented on Jul 8, 2026

    @raphaelbahat

    Any updates?

  11. dannykopping commented on Jul 8, 2026

    @dannykopping
    Collaborator

    @raphaelbahat apologies, I wasn't tagged as a reviewer on the linked PR by @kasyap1234 (thank you for the PR!).
    I will attend to it today.

  12. changed the title [-]bug: unable to use glm-5.2 via openrouter with ai gateway[/-] [+]OpenRouter returns "OpenAI is temporarily unavailable" error[/+] on Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugcommunity

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions