Skip to content
Heimdallm
Marketplace/Documentation
Documentation · Guides

Errors & rate limits

Every error, on every endpoint, uses one envelope:

{
  "error": {
    "code": 401,
    "message": "Missing or invalid API key",
    "metadata": { "error_type": "authentication" }
  }
}

code repeats the HTTP status. metadata.error_type is a stable machine-readable classifier — branch on it, not on message, which is written for humans and may change. Some errors add further metadata members, listed below where they exist. Monetary members among them (required, spendable, limit, used) are integer strings in Heimdallm's internal fixed-point unit (10⁻²⁴ USD) — compare them to each other, not to dollar figures.

Statuses

Statuserror_typeWhen
400invalid_requestThe body does not validate: a missing required field, a wrong type, an out-of-range value, malformed JSON, an unknown key inside provider.
400provider_errorThe serving endpoint rejected the request as invalid, and its answer puts the fault in the request: it refuses a parameter or value as unsupported or out of range, or a body as unparseable, or it refuses a malformed messages (a text completion's prompt) that reached it exactly as you sent it. metadata.provider_status and a short provider_message say why. The request is not tried on another endpoint, since each would refuse the same request.
400context_length_exceededThe provider rejected the request as longer than the model's context.
401authenticationThe key is missing, malformed, unknown, revoked or expired. Deliberately identical in every case.
402payment_requiredNot enough spendable balance for the request's credit hold (metadata.required, metadata.spendable), or a spend limit is reached (metadata.scope = key / workspace / account, with limit, used and limit_reset).
403permission_deniedThe key may not call this route: a management key on an inference or spending route, a route that requires a management key, an account-reader route, a sandbox grant on a route that reads or changes the account's files, batches, balance, activity or provider records, a sandbox grant naming a modified-weight model (metadata.reason = modified_weights), a refinement grant used outside its one model and route, or an account not permitted to open coding workspaces.
404not_foundNo such route, model or generation. When the id names a model family, metadata.family_variants lists the served variants (details).
404no_routeThe model exists but none of its live endpoints declares what the request asked for — a parameter, an input or output, a provider preference, a price ceiling — and metadata.rejections itemises why, per endpoint. The same request meets the same refusal until it changes (details).
408timeoutThe request was aborted client-side before it finished.
409conflictThe resource's state forbids the action: cancelling a finished batch, a generated asset that is not ready, a file store over its quota, a deposit rail that is not configured, a disabled provider source.
410not_foundA generated video or mesh that was already delivered or is past its window.
413payload_too_largeThe request body exceeds the 8 MB limit, or the larger limit of a generation route taking inline references, or the provider rejected it as too large.
416invalid_requestThe Range header asks for bytes outside a generated asset. Content-Range states its length.
422unprocessableThe body validates but cannot be served as asked: a /v1/messages reply carrying generated audio, which that dialect has no block for, or a sandbox size the deployment does not offer.
429rate_limit_exceededYour key or address hit its rate limit. Honour Retry-After.
429provider_overloadedThe provider serving the model has no free capacity, which is its limit and not the key's or account's, so more keys do not raise it. Either it answered 429 itself, and a Retry-After it sent is passed through, or it refused a request at capacity moments ago and Heimdallm is holding requests away from it, in which case Retry-After is the time left on the hold.
500serverA fault in Heimdallm. The message is always Internal server error; details stay server-side.
502provider_unavailable / provider_errorEvery eligible endpoint failed: unreachable, an unreadable response, a provider-side error, or the provider does not serve this API. A 400 or 422 from a provider whose answer does not put the fault in your request, or that names a member the marketplace wrote rather than one you sent, is a provider-side error and moves on to the next endpoint; when the last endpoint answers one, the request ends with 502 provider_error and the provider's status in metadata.provider_status. Also returned once the providers' replies to one request come to more than it may read: 512 MiB of decoded bytes, 4 GiB on a text stream, and half that for any one reply.
503no_routeThe model exists but has no live endpoint at all, so metadata.rejections is empty. Worth retrying once an endpoint returns.
503provider_overloadedThe provider serving the model answered that it is overloaded (503 or 529). This is the provider's capacity and not a limit on the key or account.
503serverThe marketplace could not serve the request for a reason of its own: the catalogue is warming up after a restart, the instance serving it is restarting or restarted mid-answer, or its database was briefly unreachable. A restart before the response starts carries Retry-After and X-Should-Retry: true; a stream already under way ends with an in-band error instead, and carries no headers. Repeat the request.
504timeoutThe provider accepted the request and then stopped: no answer in time, or a stream silent past its silence bound.

Retrying. 408, 429, 502, 503 and 504 are worth retrying with exponential backoff — routing re-runs on every attempt, so the retry may land on a different endpoint entirely. A restart of the marketplace is the case to wait out rather than give up on: it answers 503 with Retry-After: 5 and X-Should-Retry: true, and a client that keeps retrying is served by the replacement within seconds. 4xx responses other than those, a 404 no_route among them, will fail the same way until the request changes. During a routed request Heimdallm already fails over between eligible endpoints on its own; errors that no other endpoint could fix (an invalid body, a 400 provider_error, an oversized payload, a client abort) are returned immediately instead.

Provider failures carry evidence. When the terminal error came from a provider, metadata includes provider_status (their HTTP status) and usually provider_message (a short excerpt of their error text), plus provider_code where one was given. A provider rejecting our upstream credential is reported as a plain 502 — it is not your authentication problem.

For a failure attributed to the provider, metadata.provider_name names the provider whose terminal attempt failed. metadata.raw, when a response body was received, contains its original text: the HTTP body or the failing SSE event's data payload, including its whitespace. It is capped at 4,096 UTF-8 bytes without splitting a character, so a truncated JSON body may not parse. No response body is invented for a disconnect or timeout. These members are carried identically in HTTP errors and mid-stream error chunks and are omitted for caller-caused errors, blocked addresses and marketplace failures. They add no stored response-body history.

Capacity holds

An endpoint that refuses a request because it has no free capacity is held out of routing for what its Retry-After names, up to 60 seconds. When it names nothing, the hold is one second, doubling for each refusal that arrives within a minute of the previous hold ending, and shortened by up to a fifth at random so the gateway's instances do not return together; a refusal during a hold can lengthen it but does not double it. The hold applies to the endpoint that refused, not to its provider's other endpoints. While it is held, a routed request goes to another eligible endpoint, including one of the same provider; when none is left, Heimdallm answers 429 provider_overloaded itself without sending the request on, with Retry-After the shortest time left on the holds. metadata.provider_name names the provider when every held endpoint belongs to one provider and is absent otherwise. Nothing is charged for that answer.

Rate limits

Two request-rate buckets protect the public API, both over a 60-second sliding window:

BucketApplies toDefault
Per API keyEvery authenticated request, per key2,400 / minute
Per client addressUnauthenticated (catalogue) requests120 / minute

A client address is an IPv4 address, or the /64 prefix of an IPv6 address, which is the block one subscriber is assigned. A HEAD request counts against the same bucket as the GET it mirrors.

Every counted response carries the state of your bucket:

X-RateLimit-Limit: 2400
X-RateLimit-Remaining: 2397
X-RateLimit-Reset: 1755300060

X-RateLimit-Reset is Unix seconds. Each API site counts the requests it serves and the sites reconcile their counts about once a second, so X-RateLimit-Remaining is the answering site's view, and a burst spread over several sites can run past the limit for about a second before it is refused. When the bucket is exhausted the request is refused with 429 and a Retry-After header (seconds); back off until then. Rate limits count requests, not tokens — batch where the API allows it (embeddings input arrays, longer conversations per call) rather than multiplying round-trips.

{
  "error": {
    "code": 429,
    "message": "This API key has reached its per-minute request limit. The limit is the key's own, not the provider's; the X-RateLimit headers say when it resets.",
    "metadata": { "error_type": "rate_limit_exceeded" }
  }
}

Spending ceilings are a separate mechanism — a breached spend limit is a 402, described in Pricing & billing.

Errors while streaming

Once a streaming response has started, the HTTP status can no longer change. A failure then arrives in-band as a final chunk with an error member — the same envelope shape — and finish_reason: "error", followed by data: [DONE]:

data: {"id":"gen-9f2c7e1a4b6d","object":"chat.completion.chunk","created":1755300000,"model":"deepseek/deepseek-v4-flash-0731-abliterated","provider":"ImpCC","error":{"code":502,"message":"Provider disconnected","metadata":{"error_type":"provider_error"}},"choices":[{"index":0,"delta":{"content":""},"finish_reason":"error"}]}

data: [DONE]

Treat such a chunk as terminal for that request. A provider that closes its stream after part of the answer, with no finish reason, no usage report and no [DONE], fails the same way, with a 502 whose message is The provider closed the stream before the answer finished. A 503 chunk is the marketplace restarting under a stream: its message says to try again in 5 seconds, and repeating the request is correct. On /v1/messages the same failure is overloaded_error, and on /v1/responses it is server_error, the codes those clients retry. Billing uses only the usage the provider reported before the failure, and no count is inferred from output already delivered (see Pricing & billing).

metadata may carry additional keys beyond error_type — operator notes about where a failure came from. The set grows over time, so ignore keys you do not recognise; the status, the code, the message and error_type are the contract.

Correlating failures

Every inference response — errors included — carries an X-Generation-Id header, assigned before anything can fail. Quote it when reporting a problem, and use GET /generation to inspect what was recorded and charged for a request that went wrong.

DiscoverFind your next modelModel libraryAll models, versions, prices and capabilitiesBenchmarksMeasured quality, cost and time by serving configurationModel requestsAsk for a model, and vote on what is listed nextShowcaseImages, video and 3D made on the marketplaceProvidersCompare independent inference providersActivityMarketplace traffic and usageNetwork statusAvailability, latency and endpoint healthChatConversations, model settings and filesImage, video & 3DGenerate images, video and 3D assetsScene studioStage a shot in 3D, direct it and render it as a videoCoding playgroundBuild software with an AI agent on a machine of your ownOverview & routingIdentity, workspaces and routing preferencesBalance & depositsBalance, deposits, ledger and reserved fundsAPI keysKeys scoped to workspaces, limits and expirationOrganizationsTeams, members and shared workspacesRequest historyRequests, receipts, sandbox sessions and account historyReferralsInvitations and referral earningsPrivacyData settings, exports and deletionDocumentationQuickstart, SDKs, pricing and guidesAPI referenceInteractive endpoint referenceList your modelsProvider guide: requirements, the fee, payouts and what is measuredProvider payoutsMonthly statements, the marketplace fee and payout walletsProvider dashboardApply as a provider, add sources and track earnings