# Free-tier Aggregation

> Combine several providers' free tiers behind one preset endpoint with key balancing, cooldown and an opt-in paid fallback.


# Free-tier Aggregation

Bring free keys from Groq, Cerebras, SambaNova, NVIDIA, Mistral, OpenRouter, GitHub Models, Cohere, Z.ai and others, group them in a **preset**, and call it like any model. Each request goes to a key that still has budget; a `429` puts that key on cooldown.

::::steps

:::step{title="Add your provider keys"}
In **Dashboard → BYOK**, click **Add key**, pick a provider, paste the key, add a label and click **Validate & Add**. AnyRouter validates the key and shows detected limits:

- **Z.ai**: 5-hour token window plus per-minute request rate
- **Anthropic** (Claude OAuth): 5-hour, 7-day and per-model windows
- **DeepSeek**: USD credit balance
- **OpenRouter**: USD credit balance and key rate limit
- **OpenAI**: daily request and token counts (admin keys only)
- **Groq, Cerebras, SambaNova, NVIDIA, Mistral, Cohere, GitHub Models**: per-minute request and token budget from response headers

If a provider exposes no usage data, the key is saved as **Unvalidated**; set limits manually under **Advanced** if you want.
:::

:::step{title="Build a preset"}
Open **Dashboard → Presets → New**. A preset is a list of branches, each a `(model, upstream)` pair such as *Z.ai Standard API*, *Z.ai Coding Plan*, *OpenRouter* or *AnyRouter platform credits*. The same model can appear in two branches via different upstreams. Set a **weight** or **priority** per branch, then pick the mode:

- **Fallback:** Branch 1 first; Branch 2 only when every key in Branch 1 is cooled down or exhausted.
- **Weighted:** spread requests by weight (for example 70/20/10).
:::

:::step{title="Call the preset"}
```bash
curl https://anyrouter.dev/api/v1/chat/completions \
  -H "Authorization: Bearer sk-ar-your-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "@presets/duyet-coding",
    "messages": [{"role": "user", "content": "Hello"}]
  }'
```

Embeddings work the same on `/api/v1/embeddings` with `"model": "@presets/my-embeddings"`. The preset's `kind` must match the endpoint (`chat` or `embedding`), otherwise the API returns `400 preset_kind_mismatch`.
:::

::::

## How it works

The resolver picks a branch, then a key in it using your per-provider key strategy (round-robin, weighted, fallback or random, set on the BYOK page). A key that returns `429` is on a 120-second cooldown (longer if the provider sends `Retry-After`), and the next request tries the next key. When every key in every branch is exhausted the request returns `429`, unless **Paid fallback** is on.

**Paid fallback** (per preset, off by default) adds a lowest-priority "anyrouter platform" branch, so exhausted BYOK branches are served on platform credits. Cost appears in the same `cost_usd` column in the dashboard.

## Capacity card

Each preset page shows three meters: **Tokens** and **Requests** (daily budget minus used today, summed over the preset's BYOK keys) and **Platform $** (spend vs budget when paid fallback is on). Each key shows one status:

- `●` healthy
- `◐` cooldown (seconds of `Retry-After` left)
- `○` exhausted (95% or more of daily budget used)
- `✕` invalid (rejected on the last probe)

Countdowns show the next reset per window. Click **Probe all keys** to re-run every probe (3-second budget each), or probe one key with `POST /api/v1/byok/probe` and `{ "key_id": "byok_..." }`. Probes run only when you ask, not on a schedule.

## Not included

- OAuth-subscription tiers (Claude Code, GitHub Copilot, Cursor), whose terms do not allow third-party intermediation.
- Sticky sessions: every turn re-resolves the preset. Pin a single model if you need affinity.


## Related

- [Free Tier](/docs/features/free-tier.md)
- [Share a Key to the Shared Pool](/docs/features/shared-pool.md)
- [Bring Your Own Key (BYOK)](/docs/features/byok.md)
