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

> ## Agent Instructions
> The Venice API is OpenAI-compatible: use any OpenAI SDK with the base URL `https://api.venice.ai/api/v1` and a Venice API key, or pay per request from a USDC wallet through x402 with no account.
> Read model IDs from `GET /models` or `GET /models/traits` at runtime instead of hardcoding them from memory or from these pages. Models are added and retired often.
> Every model's price is in https://docs.venice.ai/pricing.md. Quote video and audio jobs with `POST /video/quote` or `POST /audio/quote` before you queue them.
> Search these docs from an MCP client at https://docs.venice.ai/mcp. The full agent guide is https://docs.venice.ai/agents.md.

# 速率限制

> Venice API 按模型和等级划分的速率限制、如何查询这些限制、用于显示容量的响应头，以及如何处理 429 错误。

速率限制因模型和等级而异。`/api_keys/rate_limits` 端点会返回您的密钥上每个模型的当前限制：

> [card] [查看您的限制](https://docs.venice.ai/zh/api-reference/endpoint/api_keys/rate_limits.md?playground=open)
>
> 交互式 playground

> [card] [速率限制日志](https://docs.venice.ai/zh/api-reference/endpoint/api_keys/rate_limit_logs.md?playground=open)
>
> 查看哪些请求达到了限制

```bash theme={"system"}
curl https://api.venice.ai/api/v1/api_keys/rate_limits \
  -H "Authorization: Bearer $VENICE_API_KEY"
```

## 按模型类型划分的限制

### 文本、嵌入和图像模型

文本、嵌入和图像模型（包括放大和局部重绘）各自有独立的限制。在 `/api_keys/rate_limits` 的响应中，`data.rateLimits` 为每个模型提供一个条目，每个条目的 `rateLimits` 会为每种限制 `type` 列出一个 `amount`：`RPM`（每分钟请求数）、`TPM`（每分钟 token 数）或 `RPD`（每天请求数）。要查看单个模型：

```bash theme={"system"}
curl -s https://api.venice.ai/api/v1/api_keys/rate_limits \
  -H "Authorization: Bearer $VENICE_API_KEY" \
  | jq '.data.rateLimits[] | select(.apiModelId == "venice-uncensored-1-2")'
```

限制可能会变化，因此请从 API 读取，而不要硬编码。推理响应还会在 `x-ratelimit-*` [响应头](#响应头)中返回所应用的限制和您的剩余容量。

### 语音和转录模型

每个语音和转录模型允许每分钟 60 个请求，使用合作伙伴密钥时为 120 个。

### 视频和音乐模型

视频、音乐和语音转换的排队和检索请求受每个账户的请求限制约束。请使用退避策略处理 `429` 响应，并以适度的间隔轮询检索端点，而不是在紧密循环中轮询。任务按每次生成从您的积分余额中计费，因此请先使用 [`POST /video/quote`](https://docs.venice.ai/zh/api-reference/endpoint/video/quote)、[`POST /audio/quote`](https://docs.venice.ai/zh/api-reference/endpoint/audio/quote) 或 [`POST /audio/voice-changer/quote`](https://docs.venice.ai/zh/api-reference/endpoint/audio/voice-changer/quote) 对任务进行估价。

## 处理错误

失败的请求（500、503、429）应使用指数退避进行重试。

对于推理端点上的 429 错误，`x-ratelimit-reset-requests` 响应头以 Unix 时间戳（毫秒）的形式给出请求窗口完全清空的最晚时间。等到该时间之后重试总是安全的；提前重试也可能成功。

```javascript theme={"system"}
const reset = Number(response.headers.get('x-ratelimit-reset-requests'));
const waitMs = Math.max(0, reset - Date.now());
await new Promise((resolve) => setTimeout(resolve, waitMs));
```

### 错误预算

另有两个限制用于保护 API，防止客户端反复重试撞墙。两者均按每个 API 密钥、每个模型计数，并且都会返回 `429`。失败请求按固定的 30 秒窗口计数：

| 预算 | 阈值 | 适用范围 |
| :- | -: | :- |
| 失败请求 | 每 30 秒 50 次 | 所有端点 |
| 不受支持的功能请求 | 每 30 秒 200 次 | `/chat/completions`、`/responses` |

第二个预算统计的是向模型请求其不支持的功能的请求。例如，向不具备视觉或工具调用能力的模型请求这些功能。超出任一预算都会在[速率限制日志](https://docs.venice.ai/zh/api-reference/endpoint/api_keys/rate_limit_logs.md)中显示为 `FAILED_REQUESTS` 或 `UNSUPPORTED_FEATURE_REQUESTS`。

响应体中的 `error` 字段会指明触发的阈值。对于失败请求预算，其内容为：

```
Too many failed attempts (> 50) resulting in a non-success status code. Please wait 30 seconds and try again. See https://docs.venice.ai/api-reference/rate-limiting for more information.
```

## 响应头

推理响应（chat completions、responses、图像、音频和嵌入）包含以下响应头。模型、API 密钥、账单或 x402 路由不会发送这些响应头，`x-venice-balance-*` 响应头同样如此。

| 响应头 | 说明 |
| :- | :- |
| `x-ratelimit-limit-requests` | 当前窗口内允许的最大请求数 |
| `x-ratelimit-remaining-requests` | 当前窗口内剩余的请求数 |
| `x-ratelimit-reset-requests` | 当前窗口完全清空时的 Unix 时间戳（毫秒）（即请求时间加上完整窗口长度，与使用量无关） |
| `x-ratelimit-limit-tokens` | 每分钟允许的最大 token 数 |
| `x-ratelimit-remaining-tokens` | 当前分钟内剩余的 token 数 |
| `x-ratelimit-reset-tokens` | token 限制重置时的 Unix 时间戳（毫秒） |

失败请求预算有其专用的响应头，会在使用 API 密钥发出的每个请求的响应中发送，包括 `401` 响应：

| 响应头 | 说明 |
| :- | :- |
| `x-ratelimit-remaining` | 当前 30 秒窗口内剩余的失败请求数 |
| `x-ratelimit-resets` | 当前 30 秒窗口重置时的 Unix 时间戳（毫秒） |

`/crypto/rpc/{network}` 端点使用自己的限制以及自己的 `X-RateLimit-Limit`、`X-RateLimit-Remaining` 和 `X-RateLimit-Reset` 响应头，这些响应头仅在 429 响应中设置。与上面以毫秒为单位的响应头不同，`X-RateLimit-Reset` 是以秒为单位的 Unix 时间戳。详情请参阅 [Crypto RPC](https://docs.venice.ai/zh/api-reference/endpoint/crypto/rpc.md)。

## 合作伙伴等级

合作伙伴密钥对每个模型都有独立的限制。使用合作伙伴密钥调用 `GET /api_keys/rate_limits` 即可查看。

如果您持续达到速率限制，并且您的使用模式显示出**长期的持续需求**，请联系我们讨论合作伙伴访问权限：[support@venice.ai](mailto:support@venice.ai)。

合作伙伴等级的限制可根据您的具体需求进行调整。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.