# Add BYOK to an Existing App

> Attach your own provider keys to AnyRouter and change one base URL, so requests bill to your provider accounts.


# Add BYOK to an existing app

Keep paying your provider directly while moving traffic through AnyRouter for logs, analytics, routing, and presets. BYOK requests have no per-token AnyRouter fee and never draw down credits; requests with no matching BYOK key use credits at the listed model price.

1. Add your provider key (OpenAI, Anthropic, and others) at [Settings → BYOK](https://anyrouter.dev/dashboard/byok). It is encrypted at rest.
2. Create an `sk-ar-` key in [Dashboard → Keys](https://anyrouter.dev/dashboard/keys). This is the only key your app sends.
3. Change the base URL and key. The request body stays the same:

   ```ts
   import OpenAI from "openai"

   const client = new OpenAI({
     baseURL: "https://anyrouter.dev/api/v1",
     apiKey: process.env.ANYROUTER_API_KEY, // sk-ar-v1-...
   })

   const completion = await client.chat.completions.create({
     model: "openai/gpt-5.4-mini",
     messages: [{ role: "user", content: "Hello from my app" }],
   })
   ```

   This request is served with your OpenAI account.

4. Optional: keep credits funded and set `"provider": { "allow_fallbacks": true }` so a rate-limited or out-of-quota BYOK provider falls back to a credit-billed upstream. See [Smart Routing](/features/routing).


## Related

- [Bring Your Own Key (BYOK)](/docs/features/byok.md)
- [BYOK Provider Setup Guide](/docs/features/byok-providers.md)
- [Migrate from OpenAI](/docs/guides/migrate-from-openai.md)
- [Migrate from Anthropic](/docs/guides/migrate-from-anthropic.md)
