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
{
"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"
}
}| Field | Type | Description |
|---|---|---|
type | string | Broad category, one of invalid_request, authentication_error, billing_error, permission_error, rate_limit_error, api_error, capacity_error. |
code | string | Specific, stable error code from the table below. |
message | string | Human-readable explanation. May change; do not parse it. |
param | string | null | The request parameter that caused the error, when there is one. |
requestId | string | Same value as the Apipods-Request-Id header. |
HTTP status codes
| Status | Meaning |
|---|---|
200 OK | The request succeeded. |
201 Created | A resource was created. |
202 Accepted | A job or asynchronous action was accepted and will complete later. |
204 No Content | The request succeeded and there is nothing to return (for example a delete). |
400 Bad Request | The request was malformed or a parameter is invalid. |
401 Unauthorized | Missing, invalid or revoked API key. |
402 Payment Required | Insufficient balance or the spend limit was reached. |
403 Forbidden | The key's scope, the user's role or a quota does not allow this. |
404 Not Found | The resource does not exist in your organization. |
409 Conflict | The resource is in the wrong state, in use, or the idempotency key conflicts. |
413 Payload Too Large | A job input exceeds the payload limit. |
429 Too Many Requests | Rate limited. See Rate limits. |
500 Internal Server Error | An error on our side. |
503 Service Unavailable | No GPU capacity for the request, or a temporary outage. |
Error codes
| Status | Type | Code | Meaning |
|---|---|---|---|
400 | invalid_request | invalid_json | The request body is not valid JSON. |
400 | invalid_request | missing_parameter | A required parameter is missing. param names it. |
400 | invalid_request | invalid_parameter | A parameter has the wrong type or is out of range. param names it. |
400 | invalid_request | unsupported_gpu_type | The gpuTypeId or gpuPoolIds value does not exist. Use a full ID from GET /gpu-types or a pool ID from GET /gpu-pools. |
401 | authentication_error | missing_api_key | No Authorization header was sent. |
401 | authentication_error | invalid_api_key | The key is malformed or does not exist. |
401 | authentication_error | revoked_api_key | The key was revoked or has expired. |
402 | billing_error | insufficient_balance | Your balance does not cover one hour of the requested resources. |
402 | billing_error | spend_limit_reached | The request would exceed the organization's monthly spend limit. |
403 | permission_error | insufficient_scope | The API key is READ but the request needs READ_WRITE. |
403 | permission_error | insufficient_role | The key's owner does not have a team role that allows this action. |
403 | permission_error | gpu_quota_exceeded | The request would exceed your plan's concurrent-GPU limit (GPUs in running pods plus running serverless workers). message names the plan and limit. |
403 | permission_error | active_workers_not_enabled | minWorkers above 0 requires Active workers, which are part of the Enterprise plan. |
404 | invalid_request | resource_not_found | No resource with this ID exists in your organization. |
409 | invalid_request | invalid_state | The action is not allowed in the resource's current state, e.g. starting a RUNNING pod. |
409 | invalid_request | resource_in_use | The resource is attached elsewhere, e.g. deleting a network volume that is mounted by a pod. |
409 | invalid_request | idempotency_conflict | The Idempotency-Key was reused with a different request body. |
413 | invalid_request | payload_too_large | The job input exceeds the payload limit for /run or /runsync. |
429 | rate_limit_error | rate_limited | Too many requests. Wait for the number of seconds in Retry-After. |
500 | api_error | internal_error | Something went wrong on our side. Safe to retry with the same Idempotency-Key. |
503 | capacity_error | no_capacity | No GPU of the requested type is free in the requested region right now. |
503 | api_error | service_unavailable | The API is temporarily unavailable. Retry with exponential backoff. |
Which errors to retry
- Retry with backoff:
429,500and503. RespectRetry-Afterwhen present. Send an Idempotency-Key onPOSTrequests 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
4xxerrors. 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.