Graphorin API reference v0.7.0
Graphorin API reference / @graphorin/provider / / WithRateLimitOptions
Interface: WithRateLimitOptions
Defined in: packages/provider/src/middleware/with-rate-limit.ts:27
Options for withRateLimit.
Stable
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
burst? | readonly | number | Burst size - defaults to requestsPerMinute / 4 (rounded up to >= 1). | packages/provider/src/middleware/with-rate-limit.ts:31 |
estimateTokens? | readonly | (req) => number | Estimator for a request's token weight (only consulted when tokensPerMinute is set). The default is the deliberate cheap heuristic ceil(textChars / 4) + (maxTokens ?? 0) - synchronous and allocation-free, because this runs in the request hot path and must not add latency or network. Wire the counter from @graphorin/provider/counters (createDefaultCounter) here when you need provider-accurate weights. | packages/provider/src/middleware/with-rate-limit.ts:51 |
mode? | readonly | "throw" | "queue" | What to do on overflow. Default 'throw'. | packages/provider/src/middleware/with-rate-limit.ts:53 |
nowImpl? | readonly | () => number | Test hook overriding Date.now. | packages/provider/src/middleware/with-rate-limit.ts:55 |
requestsPerMinute | readonly | number | Allowed requests per minute. | packages/provider/src/middleware/with-rate-limit.ts:29 |
sleepImpl? | readonly | (ms, signal?) => Promise<void> | Test hook overriding setTimeout-based wait. | packages/provider/src/middleware/with-rate-limit.ts:57 |
tokensPerMinute? | readonly | number | Optional token budget per minute (W-145). When set, each request additionally reserves its estimated token weight from a second bucket whose capacity is the full minute budget; a request whose weight exceeds the remaining budget waits (queue mode) or throws with the TPM-aware retryAfterMs (throw mode) even when the RPM bucket has room. Unset: behaviour is byte-identical to the RPM-only limiter. | packages/provider/src/middleware/with-rate-limit.ts:41 |