zed-industries/zed · error

Failed to open llama.cpp model event stream: {} {}

Error message

Failed to open llama.cpp model event stream: {} {}

What it means

Raised when the SSE request to {api_url}/models/sse returns a non-success status, so the model event stream cannot be opened. Means the llama.cpp server is unreachable, misconfigured, or rejected authentication.

Source

Thrown at crates/llama_cpp/src/llama_cpp.rs:599

    api_key: Option<&str>,
    extra_headers: &CustomHeaders,
) -> Result<BoxStream<'static, Result<ModelEvent>>> {
    let uri = format!("{api_url}/models/sse");
    let request = HttpRequest::builder()
        .method(Method::GET)
        .uri(uri)
        .header("Accept", "text/event-stream")
        .when_some(api_key, |builder, api_key| {
            builder.header("Authorization", format!("Bearer {api_key}"))
        })
        .extra_headers(extra_headers)
        .body(AsyncBody::default())?;

    let mut response = client.send(request).await?;
    if !response.status().is_success() {
        let mut body = String::new();
        response.body_mut().read_to_string(&mut body).await?;
        anyhow::bail!(
            "Failed to open llama.cpp model event stream: {} {}",
            response.status(),
            body,
        );
    }

    let reader = BufReader::new(response.into_body());
    Ok(reader
        .lines()
        .filter_map(|line| async move {
            // Each event is a single `data:` line carrying the JSON envelope;
            // other SSE lines (comments, blank separators) are ignored.
            let line = line.ok()?;
            let payload = line.strip_prefix("data:")?.trim_start();
            Some(serde_json::from_str::<ModelEvent>(payload).map_err(|error| anyhow!(error)))
        })
        .boxed())
}

View on GitHub (pinned to 5a9b9558db)

Solutions

  1. Confirm the llama.cpp server is running and its API URL is correct
  2. Check the API key/Authorization header configuration
  3. Retry if the server was momentarily unavailable
Defensive patterns

Strategy: retry

When it happens

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

Common situations: See trigger scenarios.


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