# BYOK: Bring Your Own AI Keys

> Run the /ai endpoint on your own OpenAI, Anthropic, Gemini, or compatible model. Learn BYOK metering, key validation, fallback behavior, and costs.

Canonical: https://currency-core.com/docs/byok/
Updated: 2026-11-10
Published: 2026-06-17

---
**Bring Your Own Keys (BYOK)** lets an organization run the
[/ai endpoint](/docs/ai-endpoint/) on **its own AI provider and model**. Add a
provider key, choose the model, and `/ai` routes its language-model calls through
your account. BYOK requires **Growth or higher**.

Currency intelligence is unchanged. The same tool-calling engine, reference rates,
PPP data, and historical analysis run underneath. BYOK only swaps which language
model reads the question and writes the answer.

## Supported providers

| Provider | What you provide |
|---|---|
| OpenAI | API key and model, e.g. `gpt-4o-mini` |
| Anthropic | API key and model, e.g. `claude-haiku-4-5` |
| Google Gemini | API key and model, e.g. `gemini-2.0-flash` |
| Azure OpenAI | API key, base URL, API version, deployment or model |
| OpenRouter, Groq, DeepSeek, Mistral | API key and model |
| Custom | API key, base URL, and model |

Any OpenAI-compatible `/chat/completions` endpoint with tool support works
through **Custom**. The model **must support tool calling**; without it, the
assistant cannot run conversions or analysis.

## Set it up

In the dashboard, open **AI Providers**:

1. Choose a provider and enter the **model id** exactly.
2. For Azure or Custom, add the **base URL**; Azure also needs an API version.
3. Paste the **API key**, click **Test connection**, then **Add provider**.
4. Turn on **Use my providers for /ai**.

Active providers are tried in priority order; the top provider is the primary.

## Test connection does not test tool calling

**Test connection** sends one minimal text completion with no tools. It verifies
the key, base URL, model id, and network path. It does not verify that the model
supports tool calling or returns structured `tool_calls`. After adding the
provider, run a real conversion question to confirm the model can drive the
tools.

## Metering and cost example

| Situation | Cost |
|---|---|
| BYOK on, your provider answers | One API request per tool call, no AI credit |
| BYOK off | 1 AI credit |
| BYOK on, provider fails, fallback on | 1 AI credit |
| BYOK on, provider fails, fallback off | Nothing, the request returns an error |

A BYOK answer with two conversions uses two API requests; an answer with no data
tool uses none. The `toolCalls` response field reports the count.

For example, a Growth organization with 500,000 API requests and 5,000 AI credits
sends 10,000 BYOK questions with two tool calls each. That uses 20,000 API
requests and zero AI credits. The same questions on CurrencyCore's provider
would use 10,000 credits, exceeding the allowance.

Billing is cumulative across the whole request. If any model round ran on
CurrencyCore's providers, the request is treated as native for billing, even if
your provider wrote the final answer.

BYOK requests count toward the same monthly quota, overage, and hard cap as other
API calls. See [Rate Limits](/docs/rate-limits/) and
[AI Credits](/docs/ai-credits/).

## Tool-call and token budget

**Max tool calls per request** defaults to **10**. You can configure it from **1
to 1,000**. Clearing the setting stores `null`, which the route currently treats
as an effective cap of **1,000**, not as unlimited. This caps how many tool
calls, and therefore how many billed API requests, one `/ai` call can make. The
request deadline still applies.

BYOK requests also get a larger token budget than native requests:

| Limit | Native | With BYOK |
|---|---:|---:|
| `q` token cap (approximate) | 200 | 400 |
| Total input cap (approximate) | 4,000 | 8,000 |

A native fallback does not inherit the larger BYOK budget.

## Fallback behavior

The **fallback toggle** is on by default and applies only after all active
providers fail.

- **On:** CurrencyCore answers with its own model, costing 1 AI credit. If no
  credits are available, the request fails.
- **Off:** the request returns an error. Use this when data must never leave your
  providers.

## Key validation errors

| Error | Fix |
|---|---|
| `400 invalid_input`, "An API key is required" | Paste the provider key. |
| `400 invalid_input`, "A model id is required" | Enter the exact model id. |
| `400 invalid_input`, "requires a base URL" or "requires an API version" | Add the URL for Azure or Custom, and the version for Azure. |
| `400 invalid_input`, "Base URL must use https" or "must not point at a private... address" | Use a public HTTPS endpoint. HTTP is allowed only for localhost in development. |
| `503 internal_error`, "BYOK is not configured" | The deployment has no encryption key. Contact support. |
| `503 internal_error`, "requires BYOK with fallback disabled" | No provider is usable. Re-enter the key, fix the provider, or enable fallback. |
| Test connection fails | Check the provider's message, model name, permissions, and tool support. |

A provider flagged with an unreadable key usually means the server encryption key
was rotated after the key was saved. Re-enter the provider key.

## Security

Keys are encrypted at rest with AES-GCM and decrypted only at call time. The
dashboard and API return a masked view. Removing a provider deletes its key, and
keys are sent only to the provider you configured.

## Notes

- BYOK applies to the `/ai` language model only. Rates, PPP, and history still
  come from CurrencyCore.
- Historical and PPP questions still need the Growth+ entitlement on `/ai`.
- If the organization drops below Growth, providers stop routing and the setting
  reports as unavailable.
- See [Billing](/docs/billing/) for invoices and plan changes.

## Related products

- [Pricing](/pricing/)
- [Currency API](/currency-api/)
- [MCP server](/mcp-server/)
- [Currency converter](/tools/currency-converter/)
- [Getting started](/docs/getting-started/)
