Errors and retries
Every failed call rejects with a class of the MountayaError family. The client retries what is worth retrying before it gives up.
isMountayaApiError narrows to a failure the API answered, with its status, code, errors and requestId. A timeout or a dropped connection is a MountayaConnectionError instead, and carries none of them.
A 402 is fixed in your agreement or billing settings, not in code. Its message says which.
Retries are on by default: two retries with backoff, on 429, 502, 503, 504 and network failures. A Retry-After replaces the backoff. Writes are retried safely, because each one carries an idempotency key.
A co-pilot run's stream keeps reopening on a 503 for up to two minutes before it reports the error.
Each attempt waits 30 seconds for a response by default. Set timeoutMs on the client, or on one call:
onResponse hears every answer, successes included: the operation, the status, the request id, and the rate-limit state.
Quote the requestId to support: it is the id the API recorded the request under.