zed-industries/zed · error

error during streamGenerateContent via OpenCode, status code

Error message

error during streamGenerateContent via OpenCode, status code: {:?}, body: {}

What it means

The streamGenerateContent request completed at the HTTP layer but returned a non-success status code; the status and body are surfaced from the response. This indicates the provider rejected the request (auth, quota, or invalid payload) before streaming usable content.

Source

Thrown at crates/opencode/src/opencode.rs:979

                        if let Some(line) = line.strip_prefix("data: ") {
                            match serde_json::from_str(line) {
                                Ok(response) => Some(Ok(response)),
                                Err(error) => {
                                    Some(Err(anyhow!("Error parsing JSON: {error:?}\n{line:?}")))
                                }
                            }
                        } else {
                            None
                        }
                    }
                    Err(error) => Some(Err(anyhow!(error))),
                }
            })
            .boxed())
    } else {
        let mut text = String::new();
        response.body_mut().read_to_string(&mut text).await?;
        Err(anyhow!(
            "error during streamGenerateContent via OpenCode, status code: {:?}, body: {}",
            response.status(),
            text
        ))
    }
}

View on GitHub (pinned to f4178619ac)

Solutions

  1. Check the status code: 401/403 means a bad API key, 429 means quota exhaustion, 400 means an invalid request payload
  2. Verify the model name in the request is supported by the OpenCode endpoint
  3. Retry after addressing the underlying cause; transient 5xx can simply be retried
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at crates/opencode/src/opencode.rs:979 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/b463486b9ff98d4d. Report an issue: GitHub.