Skip to content
Docs navigation: System Zero / Rate limits

Rate limits

DocsSystem ZeroRate limits Updated

Use the returned rate-limit and retry headers to pace work within your workspace's limits.

decide.sh
# Set SYSTEM_ZERO_API_KEY to your API key before running this example.
# Generate once per logical decision; reuse this key when retrying.
idempotency_key="$(uuidgen 2>/dev/null \
  || cat /proc/sys/kernel/random/uuid 2>/dev/null \
  || openssl rand -hex 16 2>/dev/null \
  || python3 -c 'from uuid import uuid4; print(uuid4())' 2>/dev/null)"
cat > request.json <<'EOF'
{
  "model": "system-zero",
  "state": "The blender I ordered arrived with a cracked jar.",
  "questions": {
    "damaged": {
      "type": "boolean",
      "instructions": "Did the item arrive damaged?"
    }
  }
}
EOF
# Headerless error responses require Python 3 to read error.code.
# If x-should-retry is present, resend only when x-should-retry is true. If the
# header is absent, resend on 429, or on 409 and 5xx only with a retryable
# error.code. No answer also retries. Wait Retry-After plus up to 10 %,
# otherwise a random wait doubling from 1 s to 30 s. Stop if Retry-After is over
# 60 s. Also stop when a 429 has no Retry-After, or a 5xx has x-should-retry but
# no Retry-After.
random() { od -An -N4 -tu4 /dev/urandom | tr -d ' '; }
# Stop resending after 10 minutes.
start=$(date +%s) attempt=0
while :; do
  : "${SYSTEM_ZERO_API_KEY:?set it first}"
  : "${idempotency_key:?could not make one}"
  rm -f reply.json
  out=$(curl https://api.rightnowai.co/v1/system-zero/decide \
    --max-time 130 -sS -o reply.json -D - -w '%{http_code}' \
    -H "Authorization: Bearer $SYSTEM_ZERO_API_KEY" \
    -H "Content-Type: application/json" \
    -H "Idempotency-Key: $idempotency_key" \
    -d @request.json)
  code=$(printf '%s' "$out" | tail -c 3)
  retry_header=$(printf '%s\n' "$out" \
    | grep -i '^x-should-retry:' | tail -n 1)
  retry=$(printf '%s\n' "$retry_header" \
    | sed 's/^[^:]*:[[:space:]]*//;s/[[:space:]]*$//')
  after=$(printf '%s\n' "$out" | grep -i '^retry-after:' \
    | tail -n 1 | sed 's/^[^:]*:[[:space:]]*//;s/[[:space:]]*$//')
  case $after in *[!0-9]*|'') after= ;; esac
  if [ -z "$retry_header" ]; then
    case $code in
      000|429) ;;
      409|5??)
        error_code=$(python3 -c 'import json, sys
try:
    print(json.load(sys.stdin).get("error", {}).get("code", ""))
except (ValueError, AttributeError):
    pass' < reply.json 2>/dev/null) || break
        case $code:$error_code in
          409:idempotency_conflict) ;;
          409:upload_in_use) ;;
          409:session_busy) ;;
          5??:service_unavailable) ;;
          5??:system_zero_unavailable) ;;
          5??:billing_settlement_error) ;;
          5??:idempotency_unavailable) ;;
          5??:limiter_unavailable) ;;
          5??:internal_error) ;;
          5??:maintenance) ;;
          5??:revoke_notice_unavailable) ;;
          *) break ;;
        esac ;;
      *) break ;;
    esac
  else
    [ "$retry" = true ] || break
    case $code in 4??|5??) ;; *) break ;; esac
  fi
  if [ -n "$after" ]; then
    after=$(printf '%s' "$after" | sed 's/^0*//')
    after=${after:-0}
    [ "$after" -le 60 ] || break
    ms=$(( after * 1000 + $(random) % (after * 100 + 1) ))
  else
    [ "$code" != 429 ] || break
    if [ -n "$retry_header" ]; then
      case $code in 5??) break ;; esac
    fi
    cap=$(( attempt < 5 ? 1000 << attempt : 30000 ))
    ms=$(( $(random) % (cap + 1) ))
  fi
  [ $(( $(date +%s) - start + ms / 1000 )) -lt 600 ] || break
  sleep "$(( ms / 1000 )).$(printf '%03d' $(( ms % 1000 )))"
  [ $(( $(date +%s) - start )) -lt 600 ] || break
  attempt=$(( attempt + 1 ))
done
echo "HTTP $code"
cat reply.json 2>/dev/null

Billing and credit purchases are not open yet. Workspace usage limits still apply; see Billing and credits.

Limits

These defaults apply unless your workspace or key has a different limit. These are usage caps.

LimitDefault
Requests a minute, per key600
Calls in flight, per workspace16
Decisions a UTC month, per workspace3,000,000
Model calls a UTC day, per workspace100,000
Requests a minute, per Playground key30

The monthly cap counts answered decisions, including Playground runs, and excludes replays. The daily cap counts every call sent to the model, including answered, refused, failed and Playground calls.

CodeAction
rate_limit_exceededWait for Retry-After and pace requests to the returned limits.
concurrency_limit_exceededReduce work in flight and follow Retry-After.
workspace_limit_exceededReduce concurrent work or input load and follow Retry-After.
monthly_cap_reachedFollow resets_at and Retry-After for the workspace's monthly cap.
playground_daily_limitWait for resets_at before another Playground run.
capacity_exhaustedWait for Retry-After and use bounded retries.

These refusals return HTTP 429. Limits can be specific to the key or workspace.

Headers

X-RateLimit-Limit
The request limit for the key window.
X-RateLimit-Remaining
What remains in that window.
X-RateLimit-Reset
The Unix second when the window resets.
Retry-After
The wait in seconds before retrying.
Retry-After-Ms
The wait in milliseconds; prefer it when both wait headers are present.

The key-window headers appear once the limiter has run. A monthly_cap_reached refusal includes monthly_request_cap, used and resets_at in error.details.

Retries

Read error.retryable and x-should-retry. Keep the same Idempotency-Key and JSON body for the decision's retries, and stop automatic retries when the flag is false.

See Idempotency for replay behavior and Errors for other refusals.