# Return typed completion errors from Cloud provider \(\#58997\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/a98485809be0d6c14a52384f5eea5327151e2986)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: a98485809be0d6c14a52384f5eea5327151e2986

Requested commit: a98485809be0d6c14a52384f5eea5327151e2986

Commit: a98485809be0d6c14a52384f5eea5327151e2986

Tree: 474271522a5f285ecd4e98e157324dfcd08ceeaa

Author: Conrad Irwin

Committer: GitHub

## Message

```
Return typed completion errors from Cloud provider (#58997)

Stop the Zed cloud LLM provider from funneling completion failures
through anyhow::Error and collapsing them into
LanguageModelCompletionError::Other (which surfaced as a generic
"Request failed.").

- perform_llm_completion now returns a typed
LanguageModelCompletionError, mapping each failure to its real variant
(SerializeRequest, HttpSend, ApiReadResponseError, and ApiError-derived
status variants).
- response_lines yields a typed ResponseStreamError so mid-stream read/
deserialize failures become ApiReadResponseError/DeserializeResponse
without a runtime downcast.
- Add a first-class PaymentRequired variant for HTTP 402 and remove the
now-dead PaymentRequiredError struct and its anyhow downcast checks.

Self-Review Checklist:

- [ ] I've reviewed my own diff for quality, security, and reliability
- [ ] Unsafe blocks (if any) have justifying comments
- [ ] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [ ] Tests cover the new/changed behavior
- [ ] Performance impact has been considered and is acceptable

Closes #ISSUE

Release Notes:

- N/A

---------

Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
Co-authored-by: zed-zippy[bot] <234243425+zed-zippy[bot]@users.noreply.github.com>
```

## Parents

- [70bb09eeaafe306d3464ec35208c64b859127e3c](https://git.cafe/gitcafe/zed/commit/70bb09eeaafe306d3464ec35208c64b859127e3c?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/a98485809be0d6c14a52384f5eea5327151e2986?format=markdown)
