Fixing 502 "Upstream request failed."
A 502 here means the connection to the model could not be made or broke before any answer, and the automatic retries did not help.
What the error says
HTTP 502
{
"error": {
"message": "Upstream request failed.",
"type": "api_error",
"code": null,
"param": null
}
}On /v1/messages this is a 500 api_error with the same message.
What causes it
This is different from a 503. A 503 means the model answered with an error. A 502 means the request to the model threw before any status came back: a network failure, a dropped connection, or a request that could not be sent. The API retries this too, after about 0.6 seconds and 1.8 seconds, within a 60 second budget, unless you cancelled.
If you cancel the request yourself (closing the tab, pressing Stop) while it is still connecting, it can also end this way. In that case nothing more reaches you anyway.
Cost
Nothing reached you, so nothing is charged. The hold placed on your balance is released.
How it shows up
SillyTavern shows an error toast with the message. OpenAI SDKs treat 502 as retryable and retry twice by default before raising InternalServerError.
Step by step fix
- Retry after a short pause; these are usually short-lived.
- If your own network is unstable, test with a tiny request from the same machine to rule out your side, for example a curl with a one-word prompt.
- Try a different model from the models page.
- If it persists across all models for several minutes, it is likely an outage; wait and retry.
Telling it apart from similar errors
If the 502 comes from your own reverse proxy or hosting (an HTML page rather than the JSON above), the request never reached the API. A 503 Model overloaded is the more common transient error; see 503. A reply that starts and then stops is a different problem; see stream cut off.
FAQ
Is a 502 my fault?
Rarely. It means the hop from the API to the model failed. The exception is a client that cancels while the request is still connecting.
Will turning streaming on or off change anything?
Not for this error. It happens before any output, streaming or not.