Docs / API reference

Errors

Errors use conventional HTTP status codes and always return a JSON body with a machine-readable code. Branch on code, never on message.

The error object

400 Bad Request
{
  "error": {
    "type": "invalid_request",
    "code": "invalid_parameter",
    "message": "gpuCount must be between 1 and 8 for NVIDIA_H100_80GB_SXM.",
    "param": "gpuCount",
    "requestId": "req_4x8m2k9q7w3tnc"
  }
}
FieldTypeDescription
typestringBroad category, one of invalid_request, authentication_error, billing_error, permission_error, rate_limit_error, api_error, capacity_error.
codestringSpecific, stable error code from the table below.
messagestringHuman-readable explanation. May change; do not parse it.
paramstring | nullThe request parameter that caused the error, when there is one.
requestIdstringSame value as the Apipods-Request-Id header.

HTTP status codes

StatusMeaning
200 OKThe request succeeded.
201 CreatedA resource was created.
202 AcceptedA job or asynchronous action was accepted and will complete later.
204 No ContentThe request succeeded and there is nothing to return (for example a delete).
400 Bad RequestThe request was malformed or a parameter is invalid.
401 UnauthorizedMissing, invalid or revoked API key.
402 Payment RequiredInsufficient balance or the spend limit was reached.
403 ForbiddenThe key's scope, the user's role or a quota does not allow this.
404 Not FoundThe resource does not exist in your organization.
409 ConflictThe resource is in the wrong state, in use, or the idempotency key conflicts.
413 Payload Too LargeA job input exceeds the payload limit.
429 Too Many RequestsRate limited. See Rate limits.
500 Internal Server ErrorAn error on our side.
503 Service UnavailableNo GPU capacity for the request, or a temporary outage.

Error codes

StatusTypeCodeMeaning
400invalid_requestinvalid_jsonThe request body is not valid JSON.
400invalid_requestmissing_parameterA required parameter is missing. param names it.
400invalid_requestinvalid_parameterA parameter has the wrong type or is out of range. param names it.
400invalid_requestunsupported_gpu_typeThe gpuTypeId or gpuPoolIds value does not exist. Use a full ID from GET /gpu-types or a pool ID from GET /gpu-pools.
401authentication_errormissing_api_keyNo Authorization header was sent.
401authentication_errorinvalid_api_keyThe key is malformed or does not exist.
401authentication_errorrevoked_api_keyThe key was revoked or has expired.
402billing_errorinsufficient_balanceYour balance does not cover one hour of the requested resources.
402billing_errorspend_limit_reachedThe request would exceed the organization's monthly spend limit.
403permission_errorinsufficient_scopeThe API key is READ but the request needs READ_WRITE.
403permission_errorinsufficient_roleThe key's owner does not have a team role that allows this action.
403permission_errorgpu_quota_exceededThe request would exceed your plan's concurrent-GPU limit (GPUs in running pods plus running serverless workers). message names the plan and limit.
403permission_erroractive_workers_not_enabledminWorkers above 0 requires Active workers, which are part of the Enterprise plan.
404invalid_requestresource_not_foundNo resource with this ID exists in your organization.
409invalid_requestinvalid_stateThe action is not allowed in the resource's current state, e.g. starting a RUNNING pod.
409invalid_requestresource_in_useThe resource is attached elsewhere, e.g. deleting a network volume that is mounted by a pod.
409invalid_requestidempotency_conflictThe Idempotency-Key was reused with a different request body.
413invalid_requestpayload_too_largeThe job input exceeds the payload limit for /run or /runsync.
429rate_limit_errorrate_limitedToo many requests. Wait for the number of seconds in Retry-After.
500api_errorinternal_errorSomething went wrong on our side. Safe to retry with the same Idempotency-Key.
503capacity_errorno_capacityNo GPU of the requested type is free in the requested region right now.
503api_errorservice_unavailableThe API is temporarily unavailable. Retry with exponential backoff.

Which errors to retry

  • Retry with backoff: 429, 500 and 503. Respect Retry-After when present. Send an Idempotency-Key on POST requests so retries are safe.
  • Retry after fixing something: 402 (top up or raise the spend limit), 409 invalid_state (wait for the resource to reach the right state).
  • Do not retry: other 4xx errors. The same request will fail the same way.

For 503 no_capacity on pod creation, try another regionId or another GPU type, or check live stock with GPU types.

import apipods

client = apipods.Client()

try:
    pod = client.pods.start("pod_8f2k1x9q")
except apipods.NoCapacityError as err:
    print("No free GPU on this host:", err.request_id)
except apipods.InvalidStateError:
    print("Pod is not EXITED")
except apipods.APIError as err:
    print(err.status, err.code, err.message)

Job failures are not HTTP errors

When your serverless handler raises an exception, the runtime API still returns 200: the job object has status: "FAILED" and an error field. HTTP errors on the runtime host only describe problems with the request itself. See Job states.