Claude Platform Docs

设置工作区速率限制

beta.organization.workspaces.rate_limits.update(rate_limit_id, **kwargs) -> BetaWorkspaceRateLimit
POST/v1/organizations/workspaces/{workspace_id}/rate_limits/{rate_limit_id}

为工作区中的某个速率限制组设置或清除速率限制覆盖值。

只有 limits 中指定的限制器类型会发生变化:整数 value 设置该类型的覆盖值,null 则清除它。未指定的类型保持其当前值。高于组织自身限制的值会被存储,但组织限制仍然适用,因此实际执行的是两者中较低的值。

返回应用此请求后目标组的条目,其格式与 GET /v1/organizations/workspaces/{workspace_id}/rate_limits 返回的格式相同。更改将在大约一小时内生效。

Parameters
workspace_id: str⁠Path parameter

The ID of the workspace.

rate_limit_id: str⁠Path parameter

The id of the organization's rate-limit entry to set overrides for.

Limits to set or clear. Unspecified limit types are unchanged.

minItems1
maxItems16

Rate limiter type. input_tokens_per_minute counts every input token, cache reads included. input_tokens_per_minute_cache_aware does not count cache reads, and on current models the organization's input-token limit usually has this type. A workspace limit of either type applies alongside the organization's limit, not in place of it. Because cache reads count toward an input_tokens_per_minute limit, it can reject requests that read mostly from the cache while the organization's limit still has room.

One of the following:
"fast_itpmca"
"fast_otpm"
"input_tokens_per_minute"
"input_tokens_per_minute_cache_aware"
"output_tokens_per_minute"
"requests_per_minute"
"tokens_per_day"
"tokens_per_minute"
"tool_uses_per_second"
value: Optional[int]

New limit value. Set to null to clear the workspace override and fall back to the organization limit.

minimum0
maximum9007199254740991
Returns
class BetaWorkspaceRateLimit: type: "workspace_rate_limit"; group; limits; ... # 3 more
Errors

Any method can also return the general HTTP errors.

SandboxEgressRestrictedErrorHTTP status 403error code sandbox_egress_restricted

The request came from a Claude sandbox with restricted network access, which is not allowed to make this request. Send it from outside the sandbox, or from a sandbox with unrestricted network access.

设置工作区速率限制
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get(
        "ANTHROPIC_API_KEY"
    ),  # This is the default and can be omitted
)
beta_workspace_rate_limit = client.beta.organization.workspaces.rate_limits.update(
    rate_limit_id="rate_limit_id",
    workspace_id="workspace_id",
    limits=[
        {
            "type": "fast_itpmca",
            "value": 0,
        }
    ],
)
print(beta_workspace_rate_limit.rate_limit_id)
Returns Examples
Response 200
{
  "group": {
    "id": "id",
    "display_name": "display_name",
    "type": "model_group"
  },
  "limits": [
    {
      "org_limit": 0,
      "source": {
        "type": "workspace"
      },
      "type": "type",
      "value": 0
    }
  ],
  "models": [
    "string"
  ],
  "rate_limit_id": "rate_limit_id",
  "type": "workspace_rate_limit",
  "workspace_id": "workspace_id"
}