Together AI API 502 Bad Gateway
Together AI is a marketplace of many model servers behind one hostname, so a 502 is usually a statement about one model, not about the platform.
📡 Monitor your APIs — know when they go down before your users do
Better Stack checks uptime every 30 seconds with instant Slack, email & SMS alerts. Free tier available.
Affiliate link — we may earn a commission at no extra cost to you
Live Together AI status right now
Establish this first. If Together AI is genuinely degraded, the attribution work below is unnecessary and you should be failing over instead of reading response headers.
A 502 is the only 5xx that is definitionally written by someone other than the component that failed. A gateway asked an upstream for a response, got something it could not use — an empty body, a reset connection, a malformed reply — and substituted an error of its own. Everything useful about a 502 follows from that one fact: your request was fine, the model may never have seen it, and the error you are reading was authored by a middleman.
Which middleman is the entire question. It might be Together AI's own edge. It might equally be your ingress controller, a service-mesh sidecar, a corporate egress proxy, a CDN, or a routing library sitting between your code and the provider. These produce an identical status code and wildly different remediation, and teams routinely spend an incident refreshing a status page for a failure their own infrastructure emitted.
30-second triage: look at the response Content-Type. JSON with a structured error envelope means Together AI answered. HTML with a <title>502 Bad Gateway</title> and a server banner means an intermediary answered and the model tier never saw your call. If it is JSON and sustained, check live Together AI status and fail over. If it is HTML, read your own gateway logs.
502 against the rest of the 5xx family
These five get filed together as “the API is broken” and then handed one retry policy, which guarantees that the policy is wrong for at least three of them. The column that matters is the last one, because it is the only one that changes what you do next.
| Code | Who authored it | Correct response |
|---|---|---|
429 | Together AI, deliberately, about your allowance | Slow down. Never fail over — you export your own pacing bug |
500 | The service, about an unhandled fault | Retry once or twice; a persistent 500 is a bug report |
502 | An intermediary — possibly yours | Identify the hop first, then one jittered retry |
503 | The service, about having no capacity | Retry with a budget, then fail over or degrade |
504 | An intermediary, about a deadline it set | Retry only if idempotent; consider raising the timeout |
502 and 504 are siblings and both are written by gateways — the difference is that a 504 means the intermediary waited and gave up, while a 502 means it got an answer it could not use. Neither tells you the upstream failed. The capacity case is covered separately in the Together AI 503 guide, and the throttling case in the Together AI 429 guide.
Know Which Side Wrote the 502
External checks run from outside your own network, so a gateway failure inside your infrastructure looks different from a provider edge failure — instead of identical, which is what your application logs show you.
Try Better Stack Free →Why Together AI returns 502 specifically
One hostname, hundreds of models, and each model is served by its own pool behind a shared gateway. That architecture produces a 502 shape you will not see at a single-model provider: the gateway is perfectly healthy, your credential is fine, the flagship model returns 200 in eighty milliseconds — and the one long-tail model your feature depends on returns 502 because its pool has no healthy backend to route to right now.
Cold and scaled-to-zero pools are the usual mechanism. A rarely-called model may have no warm backend at the instant you ask, and depending on where the failure lands you get a 502 rather than a queue. This is why "is Together AI down" is nearly always the wrong question. The right one is whether the exact model id you asked for is serving.
Sample rather than probe once. One request cannot distinguish a total failure from the far more common partial one, and the two call for different responses:
for i in $(seq 1 10); do
curl -s -o /tmp/body -w "%{http_code} %{time_total}s %{content_type}\n" \
https://api.together.xyz/v1/chat/completions \
-H "Authorization: Bearer $TOGETHER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"meta-llama/Llama-3.3-70B-Instruct-Turbo","messages":[{"role":"user","content":"ping"}],"max_tokens":1}'
doneThree columns, three answers. The status code tells you whether it failed, the elapsed time tells you whether something waited before failing, and the content type tells you who wrote the error. Ten out of ten failing with a JSON body is an incident. Two out of ten failing with an HTML body is your own infrastructure having a moment, and no amount of provider failover will fix it.
The Together AI trap: never probe liveness with a different model than the one that failed
The single most common misdiagnosis on this platform is a health check that calls a cheap flagship model, gets 200, and reports Together AI healthy while the model your product actually uses has been 502ing for twenty minutes. Capacity is per-model. A probe against a different model id is not a probe of your dependency, it is a probe of an unrelated one that happens to share a hostname.
Pin the health check to the exact model string in your production config, and label every metric and alert by model id rather than by provider. If you run a capability-ordered fallback chain, each tier needs its own probe too — otherwise a chain that looks three-deep on paper can quietly be one-deep in reality, because tiers two and three have not served a successful request in a week and nobody has been watching.
The streaming case, where the 502 never reaches your status-code metrics
If you stream, a large share of your gateway failures will never be counted as 502s at all. The response headers arrived long ago with a 200; the failure happens partway through the token stream, and what your client receives is a truncated event or an HTML error fragment spliced into a channel that was expecting server-sent events. Most SDKs raise that as a decoding error, so it lands in your logs as a parse failure in the JSON layer and your Together AI error-rate panel stays flat through the entire incident.
- Assert on the terminal event. An iterator finishing is not the same as a stream completing. If the terminal marker never arrived, the response was truncated, whatever the status code said.
- Count partial responses as their own class. Not a success, not a 5xx. They behave differently and they are the metric that moves first.
- Record bytes and tokens received on failure. A stream that died at token three is a different problem from one that died at token three hundred, and only one of them is worth showing the user.
- Decide the resume policy in advance. Re-issuing the whole prompt is the honest default and it bills twice; showing the partial output with a visible label is often the better product answer.
A retry policy that fits a 502 specifically
502s are the most retry-friendly 5xx there is — they are usually brief, usually one hop, and usually gone by the time you look. That makes blanket “never retry 5xx” advice actively wrong here. Four rules keep the retry from becoming its own incident:
- One quick jittered retry first. Randomise across the full window rather than adding a small wobble, so a fleet of clients does not resynchronise and re-burst against the first recovered backend.
- Assume the work may have happened. The gateway could not read the response; that does not mean the upstream never produced one. Send an idempotency key for anything with a side effect, and expect that a retried completion can bill twice.
- Budget by ratio, not by count. Allow retries as a fraction of recent successes so the allowance collapses on its own when almost everything is failing — no deploy required. See the Together AI retry budget guide.
- Retry against a deadline. If the user-facing request gave up eight seconds ago, attempt three is load on behalf of nobody. Propagate the deadline and skip attempts that cannot finish inside it.
If 502s persist past a handful of retries, they have stopped being transient and the failover machinery should take over — which only works if it was kept warm. The Together AI failover guide covers keeping a second path tested rather than merely configured, and the circuit breaker guide covers stopping the retries automatically.
Frequently Asked Questions
What does a 502 from the Together AI API actually mean?
It means some intermediary between your process and the model received an invalid, empty or truncated response from whatever it forwarded your request to, and wrote its own error rather than passing anything through. The crucial word is intermediary: a 502 is never authored by the component that failed, which is what makes it the hardest 5xx to attribute. Your request was almost certainly fine — 502 says nothing about your payload, your key or your model choice — so editing the request is wasted effort. The productive question is not what is wrong with the call but which hop in the path wrote the error, and that is answerable in about thirty seconds from the response itself.
How do I tell a Together AI 502 from a 502 emitted by my own proxy?
Read the content type and the body, not the status code. Together AI returns structured JSON error envelopes with recognisable fields and its own identifying response headers. Load balancers, ingress controllers, CDNs and corporate proxies return an HTML page — a short document with a title like "502 Bad Gateway" and a server banner at the bottom. If the body is HTML, the model tier never saw your request and the Together AI status page is not the document you need. That single check resolves the majority of misattributed incidents, and it costs nothing to log the first 200 bytes of every error body alongside the status code so the evidence is already captured next time.
Is a 502 the same as Together AI being down?
Not usually, and the difference matters because it changes what you should do. A genuine outage is broad, sustained and consistent across endpoints and keys. A 502 is characteristically brief, patchy and self-clearing — one hop lost one upstream connection for a moment. The test takes seconds: sample the endpoint ten times in a loop rather than once. Ten out of ten failing over several minutes is an incident and warrants failover; three out of ten failing is transient turbulence that a correct retry policy absorbs without anyone noticing. Reacting to a single 502 as though it were an outage is how teams cut over to a fallback provider for an event that had already resolved before the deploy finished.
Is it safe to retry a Together AI 502?
Safer than most 5xx, with one real caveat. A 502 is typically transient and a single retry after a short jittered delay clears it, which is why blanket "never retry 5xx" advice is wrong here. The caveat is that a 502 tells you the intermediary did not get a usable response — it does not tell you the upstream never did the work. For a chat completion that is a billing question rather than a correctness one, and it is worth knowing that a retried request can be charged twice. For anything with a side effect, propagate an idempotency key so the retry is provably the same operation rather than a second one. Cap retries against a deadline rather than a fixed count, and use full jitter so a fleet of clients does not resynchronise on recovery.
Why does a 502 show up as a JSON parse error instead of a status code in my logs?
Because of streaming. On a streamed response your client has already received a 200 and started consuming server-sent events; if a hop fails mid-stream, what arrives is either a truncated event or an HTML error fragment spliced into a stream that was expecting JSON. Most SDKs surface that as a decoding exception, so the incident lands in your logs as a parse failure and never appears in the status-code panel at all. Handle stream termination explicitly — check for the terminal event rather than assuming the iterator ending means completion — and record partial-response events as their own failure class. Otherwise your dashboards will show a healthy Together AI error rate throughout an incident your users are watching happen.
The Together AI status page is green but my model returns 502 — who is wrong?
Neither. A marketplace status page reports on the platform: the gateway, authentication, billing, and the aggregate fleet. Your 502 is about one model pool inside that fleet, which is a granularity below what any status page publishes. The way to confirm this in under a minute is to call two model ids from the same key in the same loop — the one that failed and a flagship one. If the flagship returns 200 while yours returns 502, the platform is genuinely up and your specific dependency is not, which means failover to another model rather than another provider is the cheaper and faster fix. Build that comparison into your monitoring so the answer is already on a dashboard the next time.
Should I fail over to another provider on a 502?
Only after you know which hop wrote it, which is the whole point of the content-type check. If the 502 came from an intermediary you own — an egress proxy, a mesh sidecar, an ingress controller — failing over to a second provider routes the same traffic through the same broken hop and changes nothing except your bill and your confidence. If it genuinely came from Together AI's edge and is sustained across a sampled loop, failover is the correct response and should be a config flip you have already tested rather than a change you write during the incident. The middle case — brief and patchy — wants neither: it wants one jittered retry and no human involvement at all.
Related Together AI Guides
Catch the 502 Before Your Users Report It
API Status Check watches Together AI and the rest of your stack from outside your own network, so you find out whether the gateway that failed was theirs or yours — in seconds, not after twenty minutes of reading a status page that was never going to mention it.
Start Your Free Trial →Alert Pro
14-day free trialStop checking — get alerted instantly
Next time Together AI goes down, you'll know in under 60 seconds — not when your users start complaining.
- Email alerts for Together AI + 9 more APIs
- $0 charged today — card required to start
- Cancel anytime — $9/mo after trial
🌐 Can't Access Together AI?
If Together AI is working for others but not for you, it might be an ISP or regional issue. A VPN can help bypass network-level blocks and routing problems.
Troubleshoot with a VPN
Connect from a different region to test if the issue is local to your network. Also protects your connection on public Wi-Fi.
Try NordVPN — 30-Day Money-Back GuaranteeSecure Your Together AI Account
Service outages are a common time for phishing attacks. Use a password manager to keep unique, strong passwords for every account.
Try NordPass — Free Password Manager🛠 Tools We Use & Recommend
Tested across our own infrastructure monitoring 200+ APIs daily
SEO & Site Performance Monitoring
Used by 10M+ marketers
Track your site health, uptime, search rankings, and competitor movements from one dashboard.
“We use SEMrush to track how our API status pages rank and catch site health issues early.”