> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bizyair.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Production Guidelines

> BizyAir API production best practices: concurrency limits, data retention, content moderation, billing, monitoring, and disaster recovery.

## Concurrency Quotas & Rate Limiting

The platform allocates the following limits per account, based on the plan tier:

| Limit                        | Meaning                                               | Behavior on Exceedance                               |
| ---------------------------- | ----------------------------------------------------- | ---------------------------------------------------- |
| Queued tasks                 | Total tasks simultaneously in `Queuing` + `Preparing` | New requests return 429                              |
| Running tasks                | Total tasks simultaneously in `Running`               | New requests return 429                              |
| RPM                          | API requests per minute (including create / query)    | Returns 429                                          |
| WebHook callback concurrency | Concurrent callback connections made to your URL      | Queued internally by the platform; no external error |

<Tip>
  Actual limits depend on your plan. If your business needs higher concurrency, submit an upgrade request via Profile → Plans, or contact sales.
</Tip>

**Rate-limit mitigation patterns**:

1. Use a local client queue + token bucket to control the send rate
2. Apply exponential backoff retry on 429
3. Use WebHook for long tasks to avoid occupying HTTP connections

## Data Retention & Security

| Data Type                                      | Retention              | Notes                           |
| ---------------------------------------------- | ---------------------- | ------------------------------- |
| Task metadata (status / request\_Id / elapsed) | **Long-term**          | Queryable anytime via `/detail` |
| Input files (OSS `inputs/`)                    | **30 days**            | Auto-cleaned after expiry       |
| Output files (OSS `outputs/`)                  | **15 days**            | Unrecoverable after expiry      |
| API Keys                                       | Until manually deleted | Recommend regular rotation      |

<Warning>
  Download important results to your own storage within 15 days. No recovery service is provided after expiry.
</Warning>

### Content Moderation

The platform performs automatic content moderation on input prompts, uploaded images, and generated results:

* `audit_status: 1` Not reviewed (should not appear in terminal-state tasks)
* `audit_status: 2` Approved
* `audit_status: 3` Rejected; result is inaccessible
* `audit_status: 4` Moderation error (e.g., input inaccessible)

Tasks that fail moderation **will still incur inference-time charges** — filter sensitive prompts at the business layer in advance.

## Billing & Balance

### Billing Method

Fee = `inference_cost_time` × the app's unit price. Includes:

* ✅ Inference time (`Running` stage)
* ❌ Does not include queueing, preparation, upload, or download time
* ❌ Does not include `Canceled` tasks
* ✅ Includes inference time consumed before an interruption

### Querying Balance

```bash theme={null}
curl -X GET "https://api.bizyair.ai/v1/wallet" \
  -H "Authorization: Bearer $BIZYAIR_API_KEY"
```

Response:

```json theme={null}
{
  "code": 20000, "status": true,
  "data": {
    "balance": 1250.5,
    "currency": "BZC",
    "updated_at": "2025-09-11 10:30:00"
  }
}
```

### Low-balance Alert

It's recommended to poll the balance periodically (e.g., hourly) at the application layer and trigger an alert when it drops below a threshold, to avoid production disruption caused by insufficient balance.

## Monitoring & Observability

Recommended metrics to monitor:

| Metric                        | Collection Method                      | Alert Threshold Reference |
| ----------------------------- | -------------------------------------- | ------------------------- |
| Task success rate             | Compute `Success / (Success + Failed)` | \< 95%                    |
| Average inference time        | `inference_cost_time` P50 / P95        | +50% MoM                  |
| Queue wait time               | Cumulative `Queuing` time              | > 5 min                   |
| 429 frequency                 | HTTP response distribution             | > 1% sustained for 5 min  |
| WebHook callback failure rate | Your callback service logs             | > 0.1%                    |
| Balance                       | Periodic pull from `/v1/wallet`        | \< 3 days of usage        |

## Drills & Disaster Preparedness

### Drill Checklist

* Periodically drill a fast API Key rotation after a leak (create → deploy → delete old key)
* Drill a progressive 429 degradation (reduce concurrency, apply backpressure upstream)
* Drill progressive WebHook callback failure (fall back to polling)

### Readiness Checklist

Confirm before going live:

* API Key stored in a secrets management service, **not** hard-coded
* Synchronous blocking call client read timeout ≥ 60s
* WebHook receiver verifies the `X-BizyAir-Task-Authorization` header
* WebHook receiver implements idempotency (guard against duplicate callbacks)
* Important outputs are transferred to your own OSS / S3 storage in real time
* Low-balance alerts configured
* Retry and degradation logic in place
