{"article":{"title":"Limits","breadcrumb":["Operations","Limits"],"body":"**What this solves**: Tell \"requests too fast\" apart from \"quota exhausted\", learn what each of the four rate-limit tiers limits and how to adjust them, and what happens on timeout.\n\nRate limits and quotas are not the same thing: rate limits control request frequency, quotas control how much money you can spend or how much quota you can use. Tell them apart first when troubleshooting a failure.\n\n### Quick diagnosis\n\n| Symptom | Meaning | Handling |\n|---|---|---|\n| `429` | Requests too frequent | Retry per `Retry-After` or raise the threshold |\n| `403` + a quota/limit rejection | Quota, budget, or key limit triggered | Adjust the corresponding quota, don't blindly retry |\n| `402` | Account balance insufficient | Handle top-up, credit, or platform model balance |\n\n### Suggested setup\n\n1. Go live with the default rate limits first.\n2. Observe the request peak of production traffic.\n3. Raise the key or account threshold separately for high-frequency jobs.\n4. Set a cumulative limit on child keys, so no single end user runs away.\n5. Use a Mock drill for `429`, quota exhausted, and arrears to confirm the client handles them correctly.\n\nAdjust rate limits so normal peaks get through and runaway loops stop — not to push the numbers as high as possible.\n\n### Four tiers, counted independently\n\nRate limits have four tiers, each counted independently:\n\n| Counted by | Default threshold | Good for |\n|---|---|---|\n| **Model calls (per key)** | 100/min | A runaway loop from a single end user |\n| **Model calls (account total)** | 6000/min | Ten thousand keys each making a few calls: invisible at the per-key level, but the total is already maxed out |\n| Provisioning key | 1200/min | Creating, modifying, and disabling child keys, at roughly the frequency of billing events |\n| Reconciliation / integration API | 1200/min | Read-only reports; month-end reconciliation pages through hundreds of pages by day, by key, by model |\n\n> [!WARNING]\n> **Per-key model rate limits are counted independently**: each end user has one child key, each with a default of 100/min; these calls are also subject to the account total default of 6000/min.\n\n**A streaming call counts as one call**, regardless of duration or frame count, and the count happens at authentication time.\n\n![Four rate-limit tiers, each counted independently](diagram:en-limits-four-tiers)\n\n### Response when exceeded\n\nReturns `429` with `Retry-After` (seconds).\n\n> [!WARNING]\n> **Quota exhausted is `403`, not `429`**: `429` means \"too fast, retry later\", and the client backs off and retries, whereas waiting longer won't restore an exhausted quota. See the full comparison in [Error codes](errors).\n\n### Raising the threshold\n\nAll four tiers are truly self-service via `PUT /v1/alerts/rules`: set a threshold and it takes effect, with no application and no waiting for approval.\n\n| Tier | `ruleType` | `apiKeyId` |\n|---|---|---|\n| Model calls (per key) | `HIGH_FREQUENCY` | that key |\n| Model calls (account total) | `HIGH_FREQUENCY_ACCOUNT` | omit it, it's account-level by nature |\n| Provisioning key | `HIGH_FREQUENCY` | that provisioning key |\n| Reconciliation / integration API | `HIGH_FREQUENCY` | that reconciliation key |\n\nJust include the new `threshold`. If you don't pass `action`, the platform default for this tier is used (`BLOCK`: reject once maxed out); set it to `NOTIFY` if you want notification only, without blocking.\n\n`GET /v1/alerts/rules` shows the value actually in effect for each tier right now; tiers you haven't overridden show the platform default.\n\n> [!WARNING]\n> **\"In effect\" is within a minute, not instant across the fleet.** This change takes up to 60 seconds to roll out, during which different calls may read the old value.\n\n### Child key count\n\n**The number of child keys under an account is not limited.** Ten thousand is a scale we've tested (authentication, locating by `external_id`, the first list page, and deep paging are all unaffected). There is no upper limit, and therefore no corresponding error code.\n\n> [!WARNING]\n> What *is* limited is **the number of rows returned by a single list request**: `GET /v1/keys?limit=` defaults to 100 and **maxes out at 200**; passing a larger value doesn't error; it just gets clamped to 200. Page with `next_cursor` (see [Provisioning key](provisioning)).\n\n### Circuit breaker and recovery\n\nThis group is **observability parameters, not an availability commitment** (Tare does not provide SLA numbers).\n\n| | Default |\n|---|---|\n| Consecutive failures before removal | **5** |\n| Cooldown after removal | starts at **30 seconds**, exponential backoff, capped at **300 seconds** |\n| Active probing | one round every **30 seconds**, up to 20 per round; the first round starts 60 seconds after the service starts |\n| Health statistics window | **300 seconds**, minimum 5 samples, error-rate threshold **50%** |\n| Probe timeout | connect 5 seconds / read 20 seconds |\n\n**The recovery criterion is a successful probe**, not waiting long enough: after the cooldown ends, active probing confirms it, and it's put back into the candidate pool once it passes. So the impact ceiling of a single upstream blip is \"one cooldown period + one probe interval\".\n\n> [!WARNING]\n> Circuit breaker state is **shared, not counted separately per caller**; otherwise the same failing channel would be judged repeatedly and hit the same threshold over and over.\n\n![Circuit breaker and recovery: a set of timing parameters from removal back into the candidate pool](diagram:en-limits-breaker-timeline)\n\n### Concurrency and timeouts\n\n- **Concurrent connections are not limited separately**; the per-minute request count above is the effective limit.\n- **Connecting upstream times out at 10 seconds**; failing to establish a connection counts as a failed attempt and goes to failover.\n- **Read timeout is 300 seconds, and it's the cap on the gap between two frames, not the total duration of a response**: a ten-minute-long answer won't be cut off, but an upstream that stalls for more than 5 minutes will be.\n- **The number of upstream attempts per request is not limited by default**: however many routes the model has configured, that's the maximum number of attempts. It's only truncated when the account has a limit configured separately, and a truncated candidate is recorded as `never tried` in the call details.\n\n### Next steps\n\n- See the full error code comparison: read [Error codes](errors).\n- Configure alert thresholds and actions: read [Alerts](alerts).\n- Learn about provisioning keys and child keys: read [Provisioning key](provisioning).\n- Drill over-limit and arrears: read [Mock (drill)](mock).\n- Unfamiliar term: check the [glossary](glossary).\n"},"diagrams":{"en-limits-four-tiers":"<svg viewBox=\"0 0 708 280\" width=\"708\" role=\"img\" xmlns=\"http://www.w3.org/2000/svg\">\n  <title>Four rate limits, counted apart</title>\n  <desc>Four rate limits are counted separately: model calls per key at 100 per minute, model calls per account at 6000 per minute, provisioning at 1200 per minute, and reconciliation at 1200 per minute. Model calls face both the per-key and the per-account caps.</desc>\n  <style>\n    text { font-family: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans CJK SC', system-ui, sans-serif; }\n  </style>\n\n  <!-- 浅色画布 -->\n  <rect x=\"0\" y=\"0\" width=\"708\" height=\"280\" fill=\"#ffffff\"/>\n\n  <!-- 版式算术：\n       四档摆成两行两列——它们是四个平行的计数器，不是优先级层。\n       摆成上下堆叠会读成「第一档压第二档」，而原文说的是「各自独立计数、互不挤占」。\n       两列宽 318、间距 28，于是 22..340 / 368..686；两行顶边 60 / 142，各 54 高（12px + 10px）。\n       内容左右边界 22..686，中心 354；viewBox 宽 = 664 + 两侧各 22 = 708。\n       高度 = 脚注末行基线 255 + 下伸 2.5 + 22px 边距 = 279.5，取整 280。 -->\n\n  <text x=\"354\" y=\"34\" font-size=\"16\" fill=\"#1e293b\" text-anchor=\"middle\">Four rate limits, counted apart</text>\n\n  <rect x=\"22\" y=\"60\" width=\"318\" height=\"54\" rx=\"6\" fill=\"#dbeafe\" stroke=\"#3b82f6\"/>\n  <text x=\"181\" y=\"82\" font-size=\"12\" fill=\"#1e40af\" text-anchor=\"middle\">Model calls per key: 100/min</text>\n  <text x=\"181\" y=\"100\" font-size=\"10\" fill=\"#1e40af\" text-anchor=\"middle\">Stops one user's runaway loop</text>\n\n  <rect x=\"368\" y=\"60\" width=\"318\" height=\"54\" rx=\"6\" fill=\"#dbeafe\" stroke=\"#3b82f6\"/>\n  <text x=\"527\" y=\"82\" font-size=\"12\" fill=\"#1e40af\" text-anchor=\"middle\">Model calls, account: 6000/min</text>\n  <text x=\"527\" y=\"100\" font-size=\"10\" fill=\"#1e40af\" text-anchor=\"middle\">Many keys, a few calls each, hide per key</text>\n\n  <rect x=\"22\" y=\"142\" width=\"318\" height=\"54\" rx=\"6\" fill=\"#dbeafe\" stroke=\"#3b82f6\"/>\n  <text x=\"181\" y=\"164\" font-size=\"12\" fill=\"#1e40af\" text-anchor=\"middle\">Provisioning key: 1200/min</text>\n  <text x=\"181\" y=\"182\" font-size=\"10\" fill=\"#1e40af\" text-anchor=\"middle\">Create and disable child keys</text>\n\n  <rect x=\"368\" y=\"142\" width=\"318\" height=\"54\" rx=\"6\" fill=\"#dbeafe\" stroke=\"#3b82f6\"/>\n  <text x=\"527\" y=\"164\" font-size=\"12\" fill=\"#1e40af\" text-anchor=\"middle\">Reconciliation API: 1200/min</text>\n  <text x=\"527\" y=\"182\" font-size=\"10\" fill=\"#1e40af\" text-anchor=\"middle\">Read-only. Month-end pages by day and key.</text>\n\n  <!-- 脚注 -->\n  <text x=\"354\" y=\"240\" font-size=\"10\" fill=\"#64748b\" text-anchor=\"middle\">Four separate counters. Model calls still face both 100/min per key and 6000/min per account.</text>\n  <text x=\"354\" y=\"255\" font-size=\"10\" fill=\"#64748b\" text-anchor=\"middle\">One stream is one call, counted at auth. Raise any tier yourself with PUT /v1/alerts/rules.</text>\n</svg>\n","en-limits-breaker-timeline":"<svg viewBox=\"0 0 700 430\" width=\"700\" role=\"img\" xmlns=\"http://www.w3.org/2000/svg\">\n  <title>Breaker timings, from removal back to the pool</title>\n  <desc>Five failures in a row remove a channel. Cooldown starts at 30 seconds, backs off exponentially, and caps at 300 seconds. An active probe runs every 30 seconds, at most 20 per round. A successful probe puts the channel back. Recovery is the probe, not the clock.</desc>\n  <style>\n    text { font-family: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans CJK SC', system-ui, sans-serif; }\n  </style>\n  <defs>\n    <marker id=\"arrow\" markerWidth=\"8\" markerHeight=\"8\" refX=\"2\" refY=\"4\" orient=\"auto\" markerUnits=\"userSpaceOnUse\">\n      <path d=\"M0,0 L8,4 L0,8 L2,4 z\" fill=\"#64748b\"/>\n    </marker>\n  </defs>\n\n  <!-- 浅色画布 -->\n  <rect x=\"0\" y=\"0\" width=\"700\" height=\"430\" fill=\"#ffffff\"/>\n\n  <!-- 版式算术：\n       四段时间全宽横条，22..678（宽 656），高 54（12px + 10px），\n       顶边 60 / 142 / 224 / 306，底边 114 / 196 / 278 / 360，段间 28。\n       三段连线全竖直落在内容中心 350，起点 = 上条底边 + 5，终点 = 下条顶边 - 11。\n       时间轴竖着走：四段时间上不可互换，堆叠正是它要说的顺序。\n       内容左右边界 22..678，中心 350；viewBox 宽 = 656 + 两侧各 22 = 700。\n       高度 = 脚注末行基线 405 + 下伸 2.5 + 22px 边距 = 429.5，取整 430。 -->\n\n  <text x=\"350\" y=\"34\" font-size=\"16\" fill=\"#1e293b\" text-anchor=\"middle\">Breaker timings, from removal back to the pool</text>\n\n  <path d=\"M350,119 L 350,131\" fill=\"none\" stroke=\"#64748b\" stroke-width=\"1.5\" marker-end=\"url(#arrow)\"/>\n  <path d=\"M350,201 L 350,213\" fill=\"none\" stroke=\"#64748b\" stroke-width=\"1.5\" marker-end=\"url(#arrow)\"/>\n  <path d=\"M350,283 L 350,295\" fill=\"none\" stroke=\"#64748b\" stroke-width=\"1.5\" marker-end=\"url(#arrow)\"/>\n\n  <rect x=\"22\" y=\"60\" width=\"656\" height=\"54\" rx=\"6\" fill=\"#fce7f3\" stroke=\"#ec4899\"/>\n  <text x=\"350\" y=\"82\" font-size=\"12\" fill=\"#9d174d\" text-anchor=\"middle\">1. Five failures in a row, then removed</text>\n  <text x=\"350\" y=\"100\" font-size=\"10\" fill=\"#9d174d\" text-anchor=\"middle\">A removed channel sends no bytes. The call detail records parked.</text>\n\n  <rect x=\"22\" y=\"142\" width=\"656\" height=\"54\" rx=\"6\" fill=\"#fef3c7\" stroke=\"#f59e0b\"/>\n  <text x=\"350\" y=\"164\" font-size=\"12\" fill=\"#b45309\" text-anchor=\"middle\">2. Cooldown from 30s, exponential, cap 300s</text>\n  <text x=\"350\" y=\"182\" font-size=\"10\" fill=\"#b45309\" text-anchor=\"middle\">No requests go to this channel while it cools</text>\n\n  <rect x=\"22\" y=\"224\" width=\"656\" height=\"54\" rx=\"6\" fill=\"#dbeafe\" stroke=\"#3b82f6\"/>\n  <text x=\"350\" y=\"246\" font-size=\"12\" fill=\"#1e40af\" text-anchor=\"middle\">3. A probe every 30s, at most 20 a round</text>\n  <text x=\"350\" y=\"264\" font-size=\"10\" fill=\"#1e40af\" text-anchor=\"middle\">The first round starts 60s after boot</text>\n\n  <rect x=\"22\" y=\"306\" width=\"656\" height=\"54\" rx=\"6\" fill=\"#d1fae5\" stroke=\"#22c55e\"/>\n  <text x=\"350\" y=\"328\" font-size=\"12\" fill=\"#166534\" text-anchor=\"middle\">4. Probe succeeds, back in the pool</text>\n  <text x=\"350\" y=\"346\" font-size=\"10\" fill=\"#166534\" text-anchor=\"middle\">Recovery is a successful probe, not the clock</text>\n\n  <!-- 脚注 -->\n  <text x=\"350\" y=\"390\" font-size=\"10\" fill=\"#64748b\" text-anchor=\"middle\">Breaker state is shared across instances via Redis. Otherwise each one would hit the bad channel 5 times.</text>\n  <text x=\"350\" y=\"405\" font-size=\"10\" fill=\"#64748b\" text-anchor=\"middle\">Health: 300s window, 5 samples, 50% errors. Probe connect 5s / read 20s. Observability, not an uptime promise.</text>\n</svg>\n"}}