Skip to Content
Baseera Docs

Provider keys

How your model provider key is stored, who can read it, and why it never appears in a log.

Baseera runs on your own model provider key (Anthropic, OpenAI, Google or OpenRouter). That key is the most sensitive thing you give the platform, so it has exactly one reader.

Checked, then stored encrypted

When you save a key, the platform checks its shape and makes one read-only call to a fixed provider URL, with the key in a header. A rejected key is not saved, and the message says why. Fixed URLs mean user input cannot redirect the call.

The key is then stored in Supabase Vault, which encrypts it at rest. The provider_keys table keeps only the provider, label, last 4 characters, status and a Vault pointer. Signed-in users cannot read the pointer.

Only owners and admins can add, replace or remove keys.

One read path

No API returns a key after saving. The only functions that can read one are:

  • read_agent_provider_key(), for the agent's own key, used for chat;
  • read_kb_provider_key(), for a knowledge base's own embedding key.

Both are callable by the service role, which is the runtime's gateway, and nothing else. One organization can never decrypt another's key. security_invariants lists every function that can read a key, so a new one cannot appear without review.

Removing a key destroys its Vault secret. Replacing a key keeps its id and destroys the old secret. Deleting an organization destroys its secrets.

Never logged

  • Server code logs through redactForLog from @baseera/core, which strips Anthropic, OpenAI, Google, OpenRouter and Baseera key shapes and bearer tokens.
  • Runtime tests run under a gate that fails if a key shape reaches their output.
  • The model SDK's raw error logging is turned off, because provider errors can echo the key. The runtime maps and redacts errors itself.
  • Keys travel to the database as function arguments, so statement logging must stay off on the hosted project.

How the gateway uses it

Model calls go through one gateway on the Vercel AI SDK. It contains the risk of a third-party package handling a decrypted key:

  • exact version pins, each at least two weeks old;
  • a provider client created per request with that request's key, never cached;
  • a guarded fetch that reaches only each provider's own host and path over https, refuses redirects and caps the response size;
  • the key goes in a header, never a URL;
  • response, line and tool-input size caps, so a compromised upstream cannot exhaust memory.

Key checks are throttled

Saving a key sends it to the provider once, so a compromised admin session could try to use Baseera to test stolen keys. The platform asks the database first: 10 checks a minute per person and 10 per organization, only for owners and admins. Every attempt is written to the audit log as provider_key.checked, never with the key.

Key health

Each key has a health state. If it becomes invalid or out of credit, the console shows it, and the organization's owners get one email per key per 24 hours. The email holds the provider, label, last 4 and status, never key material.

What is not done yet

For now the encryption key behind Vault is managed by Supabase. Moving to a cloud key manager is deferred, not ruled out, and would change only the three functions that touch Vault.

Next steps

On this page