Ir al contenido

Shared Rate Limiter

Esta página aún no está disponible en tu idioma.

import { pipe, withRateLimit } from "mlform";
const limiter = {
async acquire(scope, lease) {
await claimQuota(scope, lease.maxConcurrent, lease.perSecond);
return {
async release() {
await releaseQuota(scope);
},
};
},
};
const transport = pipe(
myTransport,
withRateLimit({
scope: "shared-openai-quota",
maxConcurrent: 8,
perSecond: 20,
limiter,
}),
);