zed-industries/zed · error · anyhow::Error

ChatGPT models request failed (HTTP {status}): {body}

Error message

ChatGPT models request failed (HTTP {status}): {body}

What it means

The ChatGPT models endpoint returned a non-2xx HTTP status, so list_models refuses to parse the body. The status code and response body are included in the error; common causes are an expired or invalid access token (401), rate limiting (429), or server-side errors (5xx).

Source

Thrown at crates/openai_subscribed/src/openai_subscribed.rs:727

        .header("Accept", "application/json")
        .header(
            "Authorization",
            format!("Bearer {}", credentials.access_token),
        )
        .extra_headers(&extra_headers)
        .body(AsyncBody::default())
        .context("failed to build ChatGPT models request")?;
    let mut response = http_client
        .send(request)
        .await
        .context("failed to request ChatGPT models")?;
    let status = response.status();
    let mut body = String::new();
    smol::io::AsyncReadExt::read_to_string(response.body_mut(), &mut body)
        .await
        .context("failed to read ChatGPT models response")?;
    if !status.is_success() {
        return Err(anyhow!(
            "ChatGPT models request failed (HTTP {status}): {body}"
        ));
    }

    let mut models = serde_json::from_str::<ModelsResponse>(&body)
        .context("failed to parse ChatGPT models response")?
        .models;
    models.retain(|model| model.visibility == ModelVisibility::List);
    models.sort_by_key(|model| model.priority);
    if models.is_empty() {
        return Err(anyhow!(
            "ChatGPT models response did not contain any picker-visible models"
        ));
    }
    Ok(models.into_iter().map(ChatGptModel::from).collect())
}

impl LanguageModel for OpenAiSubscribedLanguageModel {

View on GitHub (pinned to 5a9b9558db)

Solutions

  1. Inspect the HTTP status: 401/403 means the access token is stale or revoked — sign out and re-authenticate
  2. For 429 rate limits, wait before the next automatic catalog refresh
  3. For 5xx errors, retry later or check the OpenAI status page
  4. For 404, verify the models endpoint URL has not changed
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at crates/openai_subscribed/src/openai_subscribed.rs:695 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/3e73d926116f50b2. Report an issue: GitHub.