Fix an error.
What each error from the API means, the exact causes, and how to clear it in SillyTavern or your own code.
Fixing a 401 "Invalid or disabled API key" errorA 401 means the API could not match the key you sent to a live key on an account. Nothing was generated and nothing was charged.
Fixing "Missing Authorization header" on API callsThis 401 means the request arrived with no credential at all. It is different from a wrong key: the API never had anything to check.
Fixing a 402 "Account balance is too low" errorA 402 means your key is valid but the account does not have enough balance to cover the request it was about to send. Nothing was generated or charged.
Fixing "This key has reached its spend cap"This 402 means the key you used has hit the spend cap set on it. Your account may still have money; the cap stops this one key on purpose.
Fixing "Spend limit reached ... will not cover this request"This 402 means the money available to the key, after holds and caps, would not pay for the prompt plus even a minimal reply.
Fixing "Unknown model" (model_not_found)This error means the model field held an id the API does not serve. The key and balance were fine; the name was not.
Fixing a 404 "No route for POST" errorThis 404 is about the address, not your key or model. The request reached the server but at a path with no API behind it.
Fixing "maximum context length" (context_length_exceeded)This 400 means the prompt plus the reply you reserved add up to more tokens than the model can hold. It is about the request, not an outage, so retrying unchanged will fail again.
Fixing "Model does not accept images"This 400 means the request carried an image and the chosen model only reads text. Retrying the same request will fail the same way every time.
Fixing 400 "Request body is not valid JSON"These 400s mean the API could not read the request body, or the body was missing something it needs before it can do anything else.
Fixing 503 "Model overloaded. Please try again in a minute."A 503 means the model behind the API failed to answer, and the API had already retried before telling you. It is usually brief.
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.
Fixing 429 Too Many Requests when calling the APIPaid requests on this API are not answered with a 429 for sending too often. If you are seeing a 429, it is worth finding out where it really comes from.
Fixing CORS errors in JanitorAI and other browser clientsA CORS error means a web page in your browser tried to call the API directly and the browser blocked it. The API does not answer cross-origin browser requests.
Fixing an empty response in SillyTavernAn empty reply with no error means the request succeeded but no visible text came back. On this API there are a few specific reasons for that.
Fixing a streamed reply that stops mid-sentenceA stream that stops mid-sentence either hit its token limit, lost its connection, or stalled. Each one leaves different clues.
Fixing replies cut short with finish_reason "length"A reply that ends with finish_reason "length" stopped because it reached its token limit. The question is where that limit came from.
Fixing request timeouts on long generationsA timeout usually means your client gave up waiting, not that the API failed. It is most common with streaming turned off and long replies.