---
name: rightnow-system-zero
description: Call the System Zero text decision API with a key from SYSTEM_ZERO_API_KEY.
---

# System Zero API

System Zero makes structured decisions from text and returns named answers with probabilities.

## First call

Read the key from `SYSTEM_ZERO_API_KEY` in the calling process. Run these examples on a server over HTTPS. Python uses the requests package.

### cURL

```shell
# 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
```

### PowerShell

```powershell
# Set SYSTEM_ZERO_API_KEY to your API key before running this example.
if (-not $env:SYSTEM_ZERO_API_KEY) { throw "Set SYSTEM_ZERO_API_KEY first." }
# One attempt, no resend: running it again sends a new decision.
$body = @'
{
  "model": "system-zero",
  "state": "The blender I ordered arrived with a cracked jar.",
  "questions": {
    "damaged": {
      "type": "boolean",
      "instructions": "Did the item arrive damaged?"
    }
  }
}
'@
$request = @{
  Method      = "Post"
  Uri         = "https://api.rightnowai.co/v1/system-zero/decide"
  Headers     = @{
    Authorization     = "Bearer $env:SYSTEM_ZERO_API_KEY"
    "Idempotency-Key" = [guid]::NewGuid().ToString()
  }
  ContentType = "application/json; charset=utf-8"
  Body        = [Text.Encoding]::UTF8.GetBytes($body)
  TimeoutSec  = 130
}
Invoke-RestMethod @request | ConvertTo-Json -Depth 10
```

### Python

```python
# Set SYSTEM_ZERO_API_KEY to your API key before running this example.
import os
import random
import time
import uuid

import requests

api_key = os.environ.get("SYSTEM_ZERO_API_KEY")
if not api_key: raise RuntimeError("Set SYSTEM_ZERO_API_KEY first.")

url = "https://api.rightnowai.co/v1/system-zero/decide"
# Generate once per logical decision; reuse this key when retrying.
idempotency_key = str(uuid.uuid4())
headers = {
    "Authorization": f"Bearer {api_key}",
    "Idempotency-Key": idempotency_key,
}
body = {
    "model": "system-zero",
    "state": "The blender I ordered arrived with a cracked jar.",
    "questions": {
        "damaged": {
            "type": "boolean",
            "instructions": "Did the item arrive damaged?"
        }
    }
}


# 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.
def retry_wait(response, attempt):
    """Seconds to wait before resending, or None when the answer is final."""
    backoff = random.uniform(0, min(30, 2**attempt))
    if response is None:
        return backoff
    status = response.status_code
    retry = response.headers.get("x-should-retry")
    if retry is None:
        try:
            code = response.json().get("error", {}).get("code")
        except (ValueError, AttributeError):
            code = None
        conflicts = (
            "idempotency_conflict",
            "upload_in_use",
            "session_busy",
        )
        unavailable = (
            "service_unavailable",
            "system_zero_unavailable",
            "billing_settlement_error",
            "idempotency_unavailable",
            "limiter_unavailable",
            "internal_error",
            "maintenance",
            "revoke_notice_unavailable",
        )
        allowed = status == 429 or (status == 409 and code in conflicts)
        allowed = allowed or (500 <= status <= 599 and code in unavailable)
        if not allowed:
            return None
    elif retry != "true" or status < 400:
        return None
    after = response.headers.get("Retry-After", "")
    if not after.isdigit():
        if retry is not None and status >= 500:
            return None
        return None if status == 429 else backoff
    if int(after) > 60:
        return None
    return int(after) * (1 + random.random() / 10)


# Stop resending after 10 minutes.
deadline = time.monotonic() + 600
attempt = 0
while True:
    try:
        response = requests.post(url, headers=headers, json=body, timeout=130)
    except (requests.ConnectionError, requests.Timeout):
        response = None
    wait = retry_wait(response, attempt)
    if wait is None or time.monotonic() + wait >= deadline:
        break
    time.sleep(wait)
    if time.monotonic() >= deadline:
        break
    attempt += 1
if response is None:
    raise RuntimeError("No answer within 10 minutes.")
response.raise_for_status()
print(response.json()["answers"])
```

### TypeScript

```typescript
// Set SYSTEM_ZERO_API_KEY to your API key before running this example.
const apiKey = process.env.SYSTEM_ZERO_API_KEY;
if (!apiKey) {
  throw new Error("Set SYSTEM_ZERO_API_KEY first.");
}

const url = "https://api.rightnowai.co/v1/system-zero/decide";
// Generate once per logical decision; reuse this key when retrying.
const idempotencyKey = crypto.randomUUID();
const body = JSON.stringify({
  "model": "system-zero",
  "state": "The blender I ordered arrived with a cracked jar.",
  "questions": {
    "damaged": {
      "type": "boolean",
      "instructions": "Did the item arrive damaged?"
    }
  }
});

// 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.
async function retryWait(response: Response | null, attempt: number) {
  const backoff = Math.random() * Math.min(30_000, 1_000 * 2 ** attempt);
  if (response === null) return backoff;
  const { status } = response;
  const retry = response.headers.get("x-should-retry");
  if (retry === null) {
    const payload = await response.clone().json().catch(() => null);
    const code = payload?.error?.code;
    const conflicts = [
      "idempotency_conflict",
      "upload_in_use",
      "session_busy",
    ];
    const unavailable = [
      "service_unavailable",
      "system_zero_unavailable",
      "billing_settlement_error",
      "idempotency_unavailable",
      "limiter_unavailable",
      "internal_error",
      "maintenance",
      "revoke_notice_unavailable",
    ];
    const allowed = status === 429
      || (status === 409 && conflicts.includes(code))
      || (status >= 500 && status <= 599 && unavailable.includes(code));
    if (allowed === false) return null;
  } else if (retry !== "true" || status < 400) {
    return null;
  }
  const after = response.headers.get("Retry-After") ?? "";
  if (!/^\d+$/.test(after)) {
    if (retry !== null && status >= 500) return null;
    return status === 429 ? null : backoff;
  }
  if (Number(after) > 60) return null;
  return Number(after) * 1_000 * (1 + Math.random() / 10);
}

// Stop resending after 10 minutes.
const deadline = Date.now() + 600_000;
let response: Response | null = null;
for (let attempt = 0; ; attempt++) {
  response = await fetch(url, {
    method: "POST",
    headers: {
      Authorization: `Bearer ${apiKey}`,
      "Content-Type": "application/json",
      "Idempotency-Key": idempotencyKey,
    },
    body,
    signal: AbortSignal.timeout(130_000),
  }).catch((error: Error) => {
    // No answer is a timeout or a failed connection; anything else is raised.
    if (error.name === "TimeoutError" || error.cause) return null;
    throw error;
  });
  const wait = await retryWait(response, attempt);
  if (wait === null || Date.now() + wait >= deadline) break;
  await response?.body?.cancel();
  await new Promise((resolve) => setTimeout(resolve, wait));
  if (Date.now() >= deadline) break;
}
if (!response) throw new Error("No answer within 10 minutes.");
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const { answers } = await response.json();
console.log(answers);
```

## Endpoint and authentication

- API base: `https://api.rightnowai.co/v1`.
- Decision: `POST https://api.rightnowai.co/v1/system-zero/decide`.
- Send `Authorization: Bearer $SYSTEM_ZERO_API_KEY` and `Content-Type: application/json`.
- Keep the key out of browser code, files, commits and logs.
- Existing users and people with a current invitation can sign in and manage keys under API keys.

## Request

- Input is text only.
- Send model, state and questions. Use model system-zero for the alias or system-zero-1.0.0 for the reviewed pinned version.
- state is a string, a JSON object or a JSON array containing application data.
- questions maps names to a type and instructions; the answer uses the same name.
- boolean: optional criteria with true and false descriptions.
- choice: provide named options to select among.
- score: provide ordered level labels.
- Unknown fields, including messages, temperature and stream, are refused as invalid_request.

## Answers

- Boolean answers return probability. Choice answers return choice and probabilities. Score answers return score, legend and probabilities.
- Answered questions include confidence and calibration_version. Probability and confidence are ratios from 0 to 1.
- A refused question contains error with code and retryable: false. An HTTP 200 reply can contain a refusal beside other answers.

## Idempotency and retries

- Idempotency-Key is optional. Use a fresh key for a new decision; retain the same key and JSON body for its retries.
- Follow error.retryable and x-should-retry. A false retry flag ends automatic retries, including system_zero_timeout.
- Prefer Retry-After-Ms when both wait headers exist; otherwise follow Retry-After. Keep retries bounded.
- The cURL, Python and TypeScript programs retain their key during automatic retries. PowerShell makes one attempt. Rerunning a program creates a new key and starts new work.
- A stored reply can be replayed while available. If a stored answer cannot be read temporarily, the same key and body may replay it after the store recovers and before the answer expires or is evicted. Recovery is not guaranteed. A new key starts new work and may produce a different answer. An unavailable replay does not mean the original request failed.

## Limits and held features

Read the authenticated `GET https://api.rightnowai.co/v1/models` response for attested model IDs, limits and held_routes. A larger schema bound is not a serving promise.

- Image, audio, document and video input remain held. Do not generate attachment workflows for this launch.
- Persistent sessions, long context, long recordings, committee and deliberate remain held.
- session_id and prompt_cache_key are routing affinity hints; they do not open a persistent session or guarantee cached input.
- [Inputs and exact refusals](https://www.rightnowai.co/docs/system-zero/attachments).
- [Sessions and affinity](https://www.rightnowai.co/docs/system-zero/session-affinity).

## Errors

Read error.code and error.retryable, not only the HTTP status. Keep X-Request-Id or request_id for support. While access is unlisted, a caller without a valid key for an active account receives unknown_endpoint.

| Code | Status | Retryable | Action |
| --- | --- | --- | --- |
| `idempotency_key_reuse` | 400 | false | Use the original body with this key, or use a new key for changed work. |
| `invalid_idempotency_key` | 400 | false | Use a nonblank Idempotency-Key with valid ASCII characters within the accepted length. |
| `invalid_request` | 400 | false | Correct the JSON, field names, types or encoding before resending. |
| `invalid_trace_header` | 400 | false | Correct or remove X-Client-Request-Id; its value must be nonblank ASCII within the accepted length. |
| `invalid_api_key` | 401 | false | Authorization is missing, malformed or unknown; a Playground credential is not accepted as a public bearer key. Use a valid System Zero API key. |
| `account_suspended` | 403 | false | The account is suspended, blocked or waiting for access. Contact support. |
| `auth_error` | 403 | false | The API key is revoked or blocked. Replace the key; this response uses authentication_error as its type. |
| `https_required` | 403 | false | Use the HTTPS base URL. |
| `model_not_found` | 404 | false | The requested model is not offered. Choose the alias or an available pinned version. |
| `unknown_endpoint` | 404 | false | The route is unavailable. Check the base URL and path; this response does not mean the API key is invalid. |
| `method_not_allowed` | 405 | false | Use a method from the Allow response header. |
| `idempotency_conflict` | 409 | true | The same key and body is still running. Wait and retry with that key. |
| `idempotency_replay_unavailable` | 409 | false | The request completed, but the stored answer is unavailable. details.original_status records the original status. A new key starts new work; this is not a replay of the old answer. |
| `payload_too_large` | 413 | false | Reduce the whole request body. |
| `questions_too_large` | 413 | false | Send fewer or shorter questions. |
| `state_too_large` | 413 | false | Shorten the state or reduce nesting. |
| `state_too_large_unguarded` | 413 | false | Shorten or split the state. |
| `injection_suspected` | 422 | false | Remove embedded instructions from the input and send changed input. |
| `input_quarantined` | 422 | false | Change the input or contact support; do not loop on the same input. |
| `invalid_criteria` | 422 | false | Use the supported criteria shape and the served text range. |
| `question_too_large` | 422 | false | Shorten the affected question. |
| `request_refused` | 422 | false | Change the request before sending it again. |
| `workspace_quarantined` | 422 | false | Contact support about the account pause. |
| `capacity_exhausted` | 429 | true | Wait for Retry-After; retry only with bounded client backoff. |
| `concurrency_limit_exceeded` | 429 | true | The account already has its allowed work in flight. Follow Retry-After and reduce concurrency; details include max_concurrent. |
| `daily_dispatch_limit` | 429 | true | Wait until the UTC reset named by the response. |
| `monthly_cap_reached` | 429 | true | The workspace reached its monthly decision cap. Follow resets_at and Retry-After; details include monthly_request_cap and used. |
| `playground_daily_limit` | 429 | true | The Playground reached its daily limit. Wait for resets_at; details include daily_limit. |
| `rate_limit_exceeded` | 429 | true | Wait for Retry-After and pace requests to the returned limits. |
| `workspace_limit_exceeded` | 429 | true | Wait for Retry-After and reduce the workspace's concurrent work or input load. |
| `internal_error` | 500 | true | An unexpected failure was caught. Retry after the stated delay; contact support with the request ID if it persists. |
| `idempotency_unavailable` | 503 | true | Replay protection cannot answer. Retry with the same Idempotency-Key after the wait. |
| `limiter_unavailable` | 503 | true | The limiting service cannot answer. Retry after the stated delay. |
| `maintenance` | 503 | true | The API is in maintenance. Wait for Retry-After. |
| `service_unavailable` | 503 | true | Wait for Retry-After; keep the request ID if the failure persists. |
| `system_zero_unavailable` | 503 | true | Wait for Retry-After and retry when retryable is true. |
| `system_zero_timeout` | 504 | false | Shorten the work or inspect the outcome; do not automatically replay unchanged. |

## Billing

The API is not charged and the console takes no payment at launch. Workspace limits still apply. Credit purchases are not open; GET /v1/credits is held.

## Next

- [API reference](https://www.rightnowai.co/docs/system-zero/decide).
- [Errors](https://www.rightnowai.co/docs/system-zero/errors).
- [Leaked API keys](https://www.rightnowai.co/docs/system-zero/leaked-api-keys).
- [All guides](https://www.rightnowai.co/docs/system-zero/llms.txt).
