Dike logoDocs

When your application receives a 429 Too Many Requests error with code: rate_limited, use this guide to identify the specific bottleneck and adjust throughput.

Rendering diagram...

1. Pinpointing the Triggered Limit

Dike enforces two main per-minute sliding window tiers:

  1. Reasoning Quota (POST /v1/reason):
    • Limit: 10 requests / minute on Pay As You Go.
    • Common Cause: Autonomous agent loops calling dike_reason at every intermediate sub-goal.
    • Solution: Switch intermediate exploratory steps to dike_search and dike_graph_traverse, invoking dike_reason once for the final synthesis.
  2. Standard API Quota (/v1/search, /v1/cite, /v1/document/*, /v1/graph/traverse):
    • Limit: 30 req/min (Free), 120 req/min (Pay As You Go).
    • Common Cause: Unbounded parallel thread execution during bulk document processing.
    • Solution: Use an asynchronous semaphore with a maximum concurrency of 5–10 workers.

2. Automated Header-Driven Backoff (Python)

import time
import httpx

def execute_with_quota_guard(client: httpx.Client, endpoint: str, payload: dict):
    response = client.post(endpoint, json=payload)
    
    if response.status_code == 429:
        reset_timestamp = int(response.headers.get("X-RateLimit-Reset", time.time() + 15))
        sleep_duration = max(1, reset_timestamp - int(time.time()))
        print(f"Hit rate limit on {endpoint}. Sleeping {sleep_duration}s until reset window...")
        time.sleep(sleep_duration)
        return execute_with_quota_guard(client, endpoint, payload)
        
    response.raise_for_status()
    return response.json()

Next Steps

On this page