Provider Credentials And BYOK
BYOK means “bring your own key.” It lets an organization route AI calls through provider credentials that the organization owns, while Kravos.ai still manage...
Provider Credentials And BYOK
BYOK means “bring your own key.” It lets an organization route AI calls through provider credentials that the organization owns, while Kravos.ai still manages agents, retrieval, conversations, and usage reporting.
Use BYOK when you need provider-level ownership, separate provider billing, or direct access to a provider that is not available through the hosted OpenRouter path.
Supported Providers And Purposes
Provider credentials currently support:
- OpenAI
- Anthropic
- Mistral
- Groq
- OpenRouter
Each credential has a purpose:
| Purpose | Use |
|---|---|
chat | Chat and agent turns. |
embeddings | Embedding workflows. The dashboard labels this OpenAI-only. |
all | Both chat and embeddings where the provider supports it. |
BYOK must be enabled for the account. If it is not enabled, the Provider Keys UI shows a plan notice and the create endpoint returns BYOK_NOT_ALLOWED.
Add A Provider Key
- Open Organization → Provider Keys.
- Select the provider.
- Select the purpose.
- Add a human-readable label.
- Paste the provider API key.
- Select Save & Validate.
Kravos.ai stores the secret encrypted immediately, marks the credential PENDING, then validates it with the provider. Validation has a 10-second timeout.
| Status | Meaning |
|---|---|
VALID | The provider accepted the key. |
INVALID | The provider rejected the key or validation failed. |
PENDING | Validation timed out. The key is saved, but should be retested before relying on it. |
Test And Update Current Behavior
The dashboard flow currently supports adding credentials and deleting credentials. It does not expose a separate re-test button or update-secret form.
Other platform surfaces can do more:
- platform credential tools can list metadata, get one credential, create a credential, update metadata, replace the stored secret, and re-test a stored credential
- the app
PATCH /api/credentials/:idroute updates only label, default flag, and purpose; it does not replace the secret - the app
DELETE /api/credentials/:idroute soft-deactivates the credential
Replacing a secret re-validates the new value. Testing a stored credential decrypts it server-side, validates it, and returns only metadata plus validation status.
Model Selection And Fallback
Agent models use the {provider}/{model} pattern, such as anthropic/claude-sonnet-4-5. Older bare model IDs are treated as OpenAI model IDs for compatibility.
The provider/model picker asks /api/providers which providers are usable:
- OpenRouter is available as hosted when
OPENROUTER_API_KEYis configured. - Direct providers appear when the tenant has an active, valid BYOK credential with purpose
chatorall.
At runtime, model resolution works in this order:
- If BYOK is enabled and a valid active tenant credential exists for the selected provider, Kravos.ai calls that provider directly and records the turn as BYOK.
- If no tenant credential is available, Kravos.ai uses the hosted OpenRouter gateway when
OPENROUTER_API_KEYis configured and records the turn as hosted. - If neither path is configured, the turn fails with a provider-not-configured error.
Fallback is not retry-on-error
The fallback above happens when Kravos.ai resolves the model before the call. If a BYOK provider call starts and then the provider returns an error, the current runtime does not automatically retry the same turn through hosted OpenRouter.
Redaction And Secret Storage
- raw provider keys are never returned by credential list, get, create, update, or test responses
- app routes avoid selecting
encryptedSecret - platform metadata responses redact stored validation errors
- dashboard responses may show provider validation errors so admins can fix bad keys
- secrets are encrypted with
aes-256-gcmusingCREDENTIAL_ENCRYPTION_KEY
The encryption key must be a 32-byte hex string. If it is missing or invalid, secret encryption and decryption fail.
Rotation
For dashboard-only rotation:
- Add the replacement key.
- Wait for it to validate.
- Test a small agent turn with a model from that provider.
- Delete the old credential.
For platform-tool rotation, update the existing credential with a replacement secret. That path re-validates the new secret and keeps the credential ID stable.
For chat routing, Kravos.ai chooses an active, valid credential for the provider and purpose. Do not leave old valid credentials active if the provider account should no longer be used.
Audit Coverage
Current audit coverage is uneven:
- platform destructive credential deactivation writes a
credential.deleteaudit event - admin-side credential revalidation writes a
credential.revalidateaudit event - the dashboard add and delete credential routes do not currently expose a user-facing credential audit trail
Secrets are not written to audit payloads.
Troubleshooting
Provider does not appear in the model picker
- confirm BYOK is enabled for the account
- confirm the credential is
VALID - confirm the credential purpose is
chatorall - for hosted-only use, confirm
OPENROUTER_API_KEYis configured
Validation stays pending
The provider did not respond before the 10-second timeout. Re-test through a platform credential tool, or add a replacement key if the provider key might be wrong.
A turn used hosted credits instead of BYOK
Kravos.ai did not find a valid active BYOK credential for that provider at model-resolution time. Check provider, purpose, validation status, and whether BYOK is enabled for the account.
Related Docs
Usage & Costs
Separate hosted-credit usage from BYOK activity by provider and model.
Billing
Review plan features, hosted credit balance, and BYOK evaluation status.
Agent Settings
Choose the provider model that an agent should use.


