When Keys Mean More Than Access: Why API Keys and Embeddings Are Two Sides of the Same Lock

Gleb Sokolov

Hatched by Gleb Sokolov

Apr 15, 2026

9 min read

72%

0

What does a short string of characters that unlocks a cloud endpoint have in common with a 1 024 dimensional vector stored in a database? At first glance the two things sit in different worlds: one is a credential, the other is a mathematical fingerprint. Look closer and you find they are both types of keys. Both enable access, shape behavior, and concentrate power. Both can be copied, leaked, misused, and regulated. Thinking about them together reveals a single, urgent design problem: modern AI systems need a unified theory of keys rather than separate ad hoc practices for credentials and representations.

The setup: two kinds of keys in every AI system

Cloud driven AI systems typically rely on familiar security practices. Developers obtain API keys, store them in secret stores, and rotate them when compromised. That is the world of credentials. It is a world built on the idea that possession equals authority: if you hold the key you can act through the service.

At the same time a new infrastructure layer has emerged: embeddings. Embeddings convert text, images, audio and other signals into vectors. Those vectors are compact semantic fingerprints. They are the lingua franca of search, recommendation, similarity, and retrieval augmented generation. The practical pattern is simple: you map raw data to embeddings, index them, and then query with other embeddings to find neighbors.

The two flows intersect often. A request authenticated by an API key produces or consumes embeddings. Yet most teams treat the API credential and the embedding as separate engineering problems. That separation is the design tension I want to explore.

The tension: access versus representation, impermanence versus persistence

Viewing keys and embeddings as distinct invites a set of mismatches that are now causing real operational and ethical problems.

First mismatch: control models are different. API keys are explicitly revocable, auditable, and federated. They are treated as secrets. Embeddings are treated as data. Once generated, embedding vectors are stored, copied, transformed, and shared. They do not expire and are not normally revocable. The result is asymmetric risk: leak a credential and you can rotate it quickly. Leak embeddings and you may be unable to remove all downstream copies.

Second mismatch: identity models differ. Possession of an API key identifies an agent. An embedding identifies content, but content can function as identity in unexpected ways. A voice sample becomes an embedding and can be used to match a person across databases. A piece of text maps to a signature that can be linked to other documents. Embeddings can serve as long lived identifiers in practice even when they were intended as ephemeral representations.

Third mismatch: value and market dynamics are misaligned. Credentials gate access to compute and to models. Embeddings gate access to meaning, to searchability, and to downstream personalization value. Improving embedding quality raises the marginal value of stored embeddings. That means the same dataset grows more valuable over time, but governance usually lags behind. Businesses may secure API endpoints and not secure their embedding stores as rigorously, even though the embedding store houses what may be the most valuable asset.

These mismatches are not theoretical. They are the cause of surprising incidents: dashboards showing API keys that were leaked and used by strangers, and embedding based systems that start to reveal private facts because the embeddings were too specific or are used with powerful decoders. The deeper tension is about how we think of keys: keys as temporary bridges to a service, and keys as permanent encodings of knowledge and identity. Treating these as the same problem yields better design.

A unified framework: the three key layers

To reason clearly about the problem I propose a simple mental model: every AI enabled system has three key layers. Each layer requires specific controls, but they should be designed together.

  1. Access keys: these are credentials that authenticate and authorize agents. Examples include API keys, OAuth tokens, and session cookies. Their concerns are standard security matters: secrecy, rotation, least privilege, rate limiting, and audit trails.

  2. Representation keys: these are vectors, hashes, and encodings that represent content, context, and agent behavior. Examples include embeddings, perceptual hashes, and derived feature vectors. Their concerns are persistence, privacy, mutability, traceability, and provenance.

  3. Governance keys: these are the policies, metadata, and control primitives that determine who can create, use, copy, transform, and remove both access keys and representation keys. Examples include retention policies, consent records, purpose bindings, and cryptographic attestation.

Plumbing these three layers together is the work of sensible system design. When they are managed separately, accidents follow. When they are treated as a coherent stack, systems can achieve both agility and safety.

Practical analogies that make the idea concrete

Think of a public library. A library card is an access key. It proves your right to borrow books. The library catalog assigns each book a call number and subject tags. Those tags and numbers are representation keys. They allow fast retrieval and cross referencing. Governance keys are the policies that say who can borrow rare manuscripts and how long a book can be kept.

Now imagine that rather than physical cards, the library assigns a permanent audio fingerprint to each patron based on a three minute recording. That fingerprint is used to match patrons for perks. Suddenly the library is using representation keys as identity tokens. If those fingerprints leak, they cannot be rotated like library cards. The library has created a long lived risk that its access policy model was not designed to handle.

Another analogy is a map and a key. API keys open the front door to operations on the map. Embeddings are coordinates on the map. But coordinates have more power than just a point location. They carry relationships. If you can read coordinates you can reconstruct a route, infer neighborhoods, and link places across maps. In other words, representation keys expose structure that can be reassembled in unexpected ways.

How to design systems where both kinds of keys are first class citizens

Below are concrete practices that follow from the three layer model. They move teams from ad hoc security plus ad hoc data practice to integrated key aware design.

  1. Treat embeddings as sensitive. Classify embedding stores as first class secure assets. Encrypt them at rest with keys managed by a key management system. Apply role based access controls to index and query operations, not just to API endpoints.

  2. Attach origin metadata to every representation key. When you store an embedding include immutable metadata: who created it, when, which model and model version produced it, and what consent or purpose bound the creation. This makes it possible to revoke usage through governance workflows even when you cannot delete every copy immediately.

  3. Build revocation and rotation patterns for representation keys. You cannot rotate an embedding the way you rotate an API key, but you can version your index and bind contracts to a version. When a dataset becomes problematic migrate active services to a new index and mark the old index as deprecated and quarantined.

  4. Add detection and audit layers. Monitor embedding queries for anomalous patterns that indicate exfiltration or deanonymization attacks. Audit logs should connect API key actions to operations on embedding indexes so you can see who accessed what representation.

  5. Apply privacy enhancing techniques at creation time. Use data minimization, purpose limitation, and privacy preserving transforms. Consider differential privacy for aggregated embeddings, or local encoding strategies that mean a stored vector cannot be inverted to recover raw content without a secondary secret.

  6. Treat model improvements as an opportunity to re evaluate governance. When you upgrade to a higher quality embedding model you change the value and sensitivity of all previously generated vectors. Plan migrations and consent refresh strategies ahead of time.

  7. Build economic alignment. Charge and meter not only by API usage but by storage and query of representation keys. Pricing and quotas create incentives to manage the lifecycle of embeddings and to avoid hoarding sensitive fingerprints.

Each of these practices is simple in isolation. Their real power comes when they are applied together in a coherent system that understands keys in three layers.

Concrete example: an embedding driven search service

Imagine a company that offers personalized document search for enterprise customers. Implementation pattern common in the industry is: ingest documents, compute embeddings with a standard model, store embeddings in a vector index, and expose a search endpoint that takes a natural language query authenticated by an API key.

Now walk through the three layer design.

Access keys: API keys authenticate clients and determine rate limits. They are issued to customers and to internal services with clear scopes. Keys are rotated every quarter and usage is monitored.

Representation keys: each document has an embedding and a record of who provided the document, the model used, and data consent. The embedding store is encrypted and access is restricted to a narrow set of services.

Governance keys: a retention policy says embeddings derived from personnel records must be deleted at termination plus 90 days. A consent manager records whether customers allowed external research uses. The index is versioned and migrations are logged.

Now consider a leak scenario. A third party gains a copy of an API key and starts bulk querying the search endpoint to harvest the most similar documents. If the system had only access layer controls, it would rely on rate limits and blocklists. But with representation layer controls the system can detect odd query patterns that map to specific embedding vectors and throttle or quarantine those vectors. With governance metadata the system can identify vectors produced from sensitive sources and restrict their exposure. In short, the extra layers make attacks observable and containable.

Key Takeaways

  1. Treat embeddings as sensitive assets: encrypt, access control, and classify them alongside credentials.
  2. Add immutable origin metadata to every embedding so governance actions can be traced and executed even if raw vectors are copied.
  3. Design for revocation via versioning and index migration when you cannot directly rotate embeddings.
  4. Monitor query patterns to detect mass exfiltration and link API key actions to representation operations in your audit trails.
  5. Anticipate model upgrades: plan migrations, consent refreshes, and re evaluation of privacy risk when embedding quality changes.

Conclusion: keys as a design lens for AI responsible practice

We have been taught to think of keys as small pieces of text that open doors. That is a necessary perspective but no longer sufficient. In systems that convert the world into vectors for search and reasoning, keys also take the form of representations that encode identity, memory, and meaning. Those representation keys can outlive credentials, propagate silently, and create value and risk in unexpected ways.

If you accept that both are keys then you must build systems that manage both together. Doing so changes everything from how you budget for storage to how you price services, from how you monitor anomalous behavior to how you build governance that respects consent. It shifts responsibility from security teams alone to a cross functional practice that includes product, privacy, and machine learning engineering.

The next time you paste an API key into a dashboard or index a vector into a database pause and ask: who else could use this key, what would they be able to learn, and how would we remove it from circulation if we needed to? That question reframes security as stewardship, and stewardship as the design principle that will determine whether these systems deliver benefit or harm.

Keys do not simply open doors. They create patterns of access and memory. Design both with equal care.

Sources

← Back to Library

Hatch New Ideas with Glasp AI 🐣

Glasp AI allows you to hatch new ideas based on your curated content. Let's curate and create with Glasp AI :)

Start Hatching 🐣