{"record":{"id":"3b03ae0323c44956","repo":"zed-industries/zed","slug":"failed-to-connect-to-deepseek-api","errorCode":null,"errorMessage":"Failed to connect to DeepSeek API: {} {}","messagePattern":"Failed to connect to DeepSeek API: (.+?) (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/deepseek/src/deepseek.rs","lineNumber":336,"sourceCode":"            .lines()\n            .filter_map(|line| async move {\n                match line {\n                    Ok(line) => {\n                        let line = line.strip_prefix(\"data: \")?;\n                        if line == \"[DONE]\" {\n                            None\n                        } else {\n                            Some(serde_json::from_str(line).map_err(Into::into))\n                        }\n                    }\n                    Err(error) => Some(Err(anyhow!(error))),\n                }\n            })\n            .boxed())\n    } else {\n        let mut body = String::new();\n        response.body_mut().read_to_string(&mut body).await?;\n        anyhow::bail!(\n            \"Failed to connect to DeepSeek API: {} {}\",\n            response.status(),\n            body,\n        );\n    }\n}\n","sourceCodeStart":318,"sourceCodeEnd":343,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/deepseek/src/deepseek.rs#L318-L343","documentation":"DeepSeek chat-completion client, non-streaming branch: when the HTTP response status is not successful, the body is read to string and the error bails with the status code plus the provider's raw error body (deepseek.rs:336). The body usually contains DeepSeek's JSON error object naming the actual cause.","triggerScenarios":"POST to DeepSeek's API returning 401 (invalid API key), 402/429 (insufficient balance / rate limit), 404 (unknown model id), 400 (malformed request), or 5xx (provider incident); anything other than a 2xx on a non-streaming completion.","commonSituations":"Expired or rotated API key; wrong model string after DeepSeek renames models; hitting RPM/TPM limits under load; regional network blocks; provider outages.","solutions":["Match the status: 401 → fix the DeepSeek API key in Zed's settings; 402/429 → add balance or back off and retry; 404 → correct the model id; 5xx → retry with backoff later.","Read the Body text in the message — DeepSeek returns a JSON error message describing the exact problem.","Reproduce outside Zed with curl using the same key/model to confirm whether it is config or provider-side.","If behind a proxy, ensure it forwards the Authorization header and does not rewrite the request."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"# confirm key/model/network before relying on the integration\ncurl -sS -o /dev/null -w '%{http_code}' https://api.deepseek.com/chat/completions \\\n  -H \"Authorization: Bearer $DEEPSEEK_API_KEY\" \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"model\":\"deepseek-chat\",\"messages\":[{\"role\":\"user\",\"content\":\"ping\"}]}'\n# expect 200; 401 -> key, 404 -> model, 429 -> backoff","typeGuard":null,"tryCatchPattern":"Parse the status out of the error; retry 429/5xx with exponential backoff and jitter, fail fast on 400/401/404 with the provider's body message shown to the user.","preventionTips":["Keep the API key in a rotating-safe store and check it after rotation.","Pin model ids that exist on the account.","Budget for rate limits when batching completion requests."],"tags":["deepseek","llm","http","api","status-code"],"backgroundTag":"llm-api-error","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}