1. Control de frecuencia de llamadas por lotes y limitación de velocidad
Anthropic aplica límites de velocidad a nivel de organización. Diseñe los sistemas de automatización para respetar estos límites y evitar activar clasificadores antabuso:
Niveles de límite de velocidad (a agosto de 2026)
| Nivel de cuenta | RPM (solicitudes/min) | TPM (tokens/min) | Límite diario de tokens |
|---|---|---|---|
| Plan gratuito | 5 | 40,000 | 50,000 |
| Plan Pro | 50 | 200,000 | 5,000,000 |
| Plan Team | 100 | 400,000 | 10,000,000 |
| Enterprise | Personalizado | Personalizado | Negociado |
Implementación de limitador de velocidad adaptativo
class AdaptiveRateLimiter {
private requestQueue: Array<() => Promise> = [];
private activeRequests = 0;
private maxConcurrency: number;
private minDelay: number; // ms between requests
constructor(rpm: number, maxConcurrency = 5) {
this.maxConcurrency = maxConcurrency;
this.minDelay = (60 / rpm) * 1000;
}
async execute(fn: () => Promise): Promise {
while (this.activeRequests >= this.maxConcurrency) {
await new Promise(resolve => setTimeout(resolve, 100));
}
this.activeRequests++;
try {
const result = await fn();
await new Promise(resolve => setTimeout(resolve, this.minDelay));
return result;
} catch (error: any) {
if (error.status === 429) {
// Rate limit hit, exponential backoff
const retryAfter = error.headers?.['retry-after'] || 60;
await new Promise(resolve => setTimeout(resolve, retryAfter * 1000));
return this.execute(fn); // Retry
}
throw error;
} finally {
this.activeRequests--;
}
}
}
// Usage
const limiter = new AdaptiveRateLimiter(50); // 50 RPM for Pro tier
const results = await Promise.all(
prompts.map(prompt => limiter.execute(() => callClaude(prompt)))
);
2. Evitar la detección antabuso
Los clasificadores del backend de Anthropic detectan patrones indicativos de destilación de modelos o scraping no autorizado. Imitar un comportamiento similar al humano ayuda a evitar marcas:
Técnicas de simulación de comportamiento humano
- Variación de prompts: Añada variabilidad en lenguaje natural a los prompts. Evite enviar 1000 solicitudes casi idénticas.
- Inyección de jitter: Aleatorice los retrasos entre solicitudes (por ejemplo, distribución uniforme de 100-3000 ms).
- Límites de sesión: Agrupe el trabajo en sesiones de 20-50 solicitudes, separadas por pausas de 5-10 minutos.
- Variación de longitud de salida: Varíe
max_tokensentre solicitudes para evitar patrones de salida de longitud fija.
Ejemplo de variación de prompts
const templates = [
"Refactor this code:
{code}",
"Can you improve this function?
{code}",
"Please optimize:
{code}",
"How would you rewrite this?
{code}",
];
function varyPrompt(code: string): string {
const template = templates[Math.floor(Math.random() * templates.length)];
const prefix = Math.random() > 0.5 ? "Here's my code: " : "";
return prefix + template.replace("{code}", code);
}
3. Sondeo multi-cuenta y balanceo de carga
Distribuya cargas de trabajo de alto volumen entre varias cuentas de Claude para evitar los límites de velocidad por organización y reducir el riesgo de destilación:
Balanceador de carga round-robin
class MultiAccountBalancer {
private accounts: Array<{ apiKey: string; weight: number }>;
private currentIndex = 0;
private requestCounts: Map = new Map();
constructor(accounts: Array<{ apiKey: string; weight?: number }>) {
this.accounts = accounts.map(acc => ({
apiKey: acc.apiKey,
weight: acc.weight || 1
}));
}
getNextAccount(): string {
// Weighted round-robin selection
const totalWeight = this.accounts.reduce((sum, acc) => sum + acc.weight, 0);
let random = Math.random() * totalWeight;
for (const account of this.accounts) {
random -= account.weight;
if (random <= 0) {
this.requestCounts.set(account.apiKey,
(this.requestCounts.get(account.apiKey) || 0) + 1);
return account.apiKey;
}
}
return this.accounts[0].apiKey;
}
getStats(): Record {
return Object.fromEntries(this.requestCounts);
}
}
// Usage
const balancer = new MultiAccountBalancer([
{ apiKey: "sk-ant-api03-...", weight: 2 }, // Pro account, higher weight
{ apiKey: "sk-ant-api04-...", weight: 1 }, // Free account, lower weight
]);
async function callWithBalancing(prompt: string) {
const apiKey = balancer.getNextAccount();
return await anthropic.messages.create({
apiKey,
model: "claude-sonnet-4.5-high",
messages: [{ role: "user", content: prompt }],
});
}
4. Registro de auditoría y lista de verificación de cumplimiento
Mantenga registros completos de la actividad de automatización para auditorías de cumplimiento y depuración:
Esquema de registro de auditoría
interface AuditLog {
timestamp: string;
accountId: string;
requestId: string;
model: string;
inputTokens: number;
outputTokens: number;
cacheHit: boolean;
latencyMs: number;
statusCode: number;
errorMessage?: string;
sourceIP: string;
userAgent: string;
}
// Log every API call
async function auditedCall(prompt: string): Promise {
const start = Date.now();
try {
const response = await anthropic.messages.create({...});
await logAudit({
timestamp: new Date().toISOString(),
accountId: "org-123",
requestId: response.id,
model: response.model,
inputTokens: response.usage.input_tokens,
outputTokens: response.usage.output_tokens,
cacheHit: response.usage.cache_read_input_tokens > 0,
latencyMs: Date.now() - start,
statusCode: 200,
sourceIP: await getPublicIP(),
userAgent: "my-automation/1.0",
});
return response;
} catch (error: any) {
await logAudit({
timestamp: new Date().toISOString(),
statusCode: error.status || 500,
errorMessage: error.message,
latencyMs: Date.now() - start,
...
});
throw error;
}
}
Lista de autocomprobación de cumplimiento
- Todas las solicitudes automatizadas usan claves API, no tokens de sesión obtenidos de forma indebida
- La automatización respeta los límites de velocidad de Anthropic (sin intentos agresivos de eludirlos)
- La salida se usa para herramientas internas, no para reventa ni entrenamiento público de modelos
- Los registros se conservan 90 días como pista de auditoría
- Se usan IP residenciales para el tráfico API (sin IP de centros de datos en automatización de alto volumen)
- No hay ataques de inyección de prompts ni intentos de jailbreak en flujos automatizados