In Build Keys and models
B / Build

Keys and models

Distributing, scoping, rotating, and metering model credentials. BYOK, local models, models through your own cloud, and BAA-covered endpoints.

View as Markdown

A model API key is a bearer credential tied to a billing account. Provider keys may have no expiry, so distribution and rotation need explicit controls.

Central key distribution

A team that needs model access may open a provider account with a corporate card and put the key in a shared document. Copies then reach other teams, repositories, and CI systems. Once the original owner changes roles, rotation becomes difficult because no one has a complete dependency list.

Missing key distribution predictably creates unmanaged copies. Training may reduce some copies, but it cannot provide inventory, expiry, or revocation.

Manage provider keys through a service that issues scoped credentials and supports expiry:

  • Applications and tools authenticate to an internal gateway with their own identity. The gateway holds the provider credential.
  • The gateway records the application, team, and user for every call. That record supports cost and traces.
  • Keep provider-key rotation inside the gateway so consumers do not need a coordinated change window.
  • Revoke one consumer without interrupting other users of the provider key.

Model access options

Vendor SaaS endpoints are quick to adopt and place more control with the provider. They fit many internal workloads, while policy may exclude them for sensitive data.

With BYOK, a product uses credentials from your provider account under your billing and data-processing terms. Where the product vendor does not receive the underlying data, this can keep processing inside the regulated organization's provider account.

Models served through your cloud account run under its contract, network boundary, and audit regime. This route may avoid a separate provider relationship.

Local or self-hosted models support environments where data cannot leave a defined boundary. They also reduce dependence on a provider's model-retirement schedule.

Protected health information requires an endpoint covered by a Business Associate Agreement. Coverage is a contractual fact that the routing layer needs in its policy data.

Supporting several routes calls for centralized Control policy. Applications should receive an approved endpoint without implementing the decision themselves.

Usage attribution

Metering records who consumed model capacity and how much they used. Billing determines who pays. Usage records are useful before internal chargeback begins.

Without attribution, an unexpected invoice can trigger a broad spend cap. Per-consumer records let teams find the batch job or application responsible and respond at that scope.

At the gateway, record the model, input and output tokens, latency, application, team, and user for every call. Cost depends on this record.

Consequences of a misplaced key

A leaked key permits unauthorized spend and authenticated access to the provider account. Depending on the provider, that account may also contain fine-tuned models, uploaded files, assistant configurations, and request logs.

Failure mode RS

A public ClickHouse instance with a million log lines and the API keys

DeepSeek / 2025

Wiz Research found two open ports on DeepSeek infrastructure leading to a ClickHouse database with no authentication. It held over a million log entries including chat history, API keys, and backend service detail, queryable by anyone over HTTP.

The skipped letter. Run. Data plane and control plane provisioned without the guardrails the rest of the stack gets. For the enterprise consuming that endpoint the skipped letter is Secure: nobody asked where the prompts land, in what form, or for how long.

Wiz Research: exposed DeepSeek database leaking sensitive information

Questions to ask your vendor, or your own team

  • How many provider API keys exist in the organization, and which inventory supplies the count?
  • Can you rotate the primary provider key this afternoon without a change window?
  • For a single inference call last week, can you name the app, the team, and the user?
  • Which access paths do you support today, and which are you one incident away from needing?
  • Where is it recorded that a given endpoint is BAA-covered, and does anything enforce it?
  • Is anyone sending IP, PII, or PHI to an endpoint with no agreement covering it? Check expense reports as well as network telemetry.
  • If a key leaked tonight, what else in the provider account would the holder reach?