Skip to content

SmartFetch

SmartFetch is a persistent stateful agent that fixes client API failures and prevents outages across all services, regions, and providers.

Core trick

Classifies API errors with an LLM, then applies retries, credential rotation, or endpoint and region failover.

Tags

Description

SmartFetch is a persistent stateful agent that fixes client API failures and prevents outages across all services, regions, and providers. It detects API key deprecations, rate limits, quota exhaustion, schema drift, endpoint changes, regional failures, and provider outages in real time. The system repairs malformed requests, infers new schemas, rotates credentials, selects alternate endpoints, and switches to healthy regions or providers when services fail. Gemini provides the reasoning needed to classify errors, generate corrected payloads, and choose the right healing action. The system learns new patterns over time and builds custom healing rules for each API. This creates a fully autonomous reliability layer that solves a broad range of client-side API problems and keeps applications functioning during failures of any kind. In the video we tested fixing a broken API connection to OpenAI, which is quite funny.... Gemini fixing the mistakes of OpenAI.
sajeevmagesh/api-battle-healer★ 00 forksJavaScriptCreated Dec 6, 2025 · last push Dec 7, 2025

README excerpt

# api-battle-healer

## FastAPI Mock Server

Install dependencies:

```bash
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
```

Run the server:

```bash
uvicorn backend.main:app --reload --host 0.0.0.0 --port 8000
```

### Endpoints

1. `POST /generate-api-key`
   - Body: `{ "userId": "demo-user" }`
   - Returns a token with quotas, retry budget, and TTL.

2. `POST /refresh-token`
   - Body: `{ "token": "<old>" }` (optional) to rotate credentials without waiting for expiry.

3. `GET|POST /simulate-budget`
   - Inspect or mutate per-token quota/ budget counters to force 402/429 behavior.

4. `GET|POST /queue-failed`
   - `POST` accepts structured request metadata (correlation ID, endpoint, provider, region, sanitized headers/body, error context) and enqueues it for async replay. A background worker replays queued requests with exponential backoff, marks entries as completed/dead, and emits `QUEUE_OVERFLOW` / `QUEUE_REPLAY_*` warnings. Persistence & external notifications are still TODO for now.

5. `POST /mock-response`
   - Return graceful-degradation payloads or feed your own fallback body.

6. `GET|POST /log`
   - Collect structured healing logs; `GET /log` echoes recent entries.

7. `GET|POST /external-api`
   - Requires `Authorization: Bearer <token>`.
   - Supports dev-time triggers (comma-delimited) through:
     - Header `X-Simulate-Failure: region_down,retryable_500,schema_drift,...`
     - Query string `?simulate=mock` or `?simulate=r

Team