How API Keys Work
API keys are static credentials — long-lived strings that grant access to an API. They work on a simple principle: if you have the key, you have access. Most API key systems provide scope-based restrictions, letting you limit a key to specific endpoints or operations like "read-only" or "billing:write."
This model works well for server-to-server communication where both sides are controlled by the same team. The key authenticates the caller, the scopes define what it can access, and rate limits prevent abuse. It's straightforward, well-understood, and easy to implement.
For human-driven applications, API keys are typically managed by developers who understand the consequences of each scope they enable. The human makes judgment calls about when and how to use the access the key provides.
Limitations of API Keys for AI Agents
When an AI agent holds an API key, the assumptions behind key-based access break down. Agents don't exercise judgment about individual actions — they execute tool calls based on model outputs. This creates several problems:
- No per-action evaluation — an API key grants blanket access to everything within its scopes. There's no mechanism to evaluate whether a specific action is appropriate given the context, cost, or risk level.
- No spending limits — if a key has billing access, the agent can make unlimited purchases. There's no built-in way to say "allow purchases under $50 but require approval above that."
- No human-in-the-loop — API keys don't support approval workflows. Every action the key permits happens immediately with no opportunity for human review of individual decisions.
- No proof of authorization — an API key proves the caller has credentials, but it doesn't prove that a specific action was authorized by the key's owner at a specific time. There's no auditable record linking a decision to an authorization check.
- Leaked keys mean full access — if an agent's API key is exposed through logs, error messages, or a compromised dependency, the attacker gets the same access the agent had. There's no way to limit the blast radius of a single key.
These limitations are manageable when humans are in the loop making decisions. They become critical when autonomous agents are making hundreds of API calls without human oversight.
How OpenLeash Differs
OpenLeash takes a fundamentally different approach: instead of granting broad access upfront, every action is evaluated individually against declarative policies. The agent doesn't hold a static credential that grants blanket access — it requests authorization for each specific action before executing it.
- Per-action policy evaluation — each action the agent wants to perform is evaluated against YAML policies that consider the action type, target, cost, and context. The same agent might be allowed to send a $10 payment but denied a $1,000 one.
- Contextual decisions — policies can factor in cost thresholds, counterparty trust levels, time of day, and cumulative spending. The authorization decision adapts to the specific situation rather than applying a static yes/no.
- Cryptographic proof tokens — when an action is allowed, OpenLeash issues a PASETO v4.public token that cryptographically proves the agent was authorized for that specific action at that specific time. Counterparties can verify these tokens independently.
- Approval workflows — policies can require human approval for high-risk actions. The agent pauses, the owner reviews the request, and execution only continues after explicit authorization.
- Append-only audit trail — every authorization request and decision is logged in an immutable audit log, creating a complete record of what the agent was authorized to do and when.
The key difference is granularity. API keys operate at the credential level — you either have access or you don't. OpenLeash operates at the action level — each individual action is evaluated, authorized, and recorded.
When API Keys Are Enough
API keys remain the right choice in many scenarios. Not every agent interaction requires per-action authorization:
- Simple internal tools — if your agent only reads data from internal APIs with no financial or security implications, API keys with read-only scopes work fine.
- Low-risk read-only APIs — querying weather data, looking up public information, or fetching search results don't need per-action governance.
- Trusted environments — when the agent, the API, and the infrastructure are all controlled by the same team, and the consequences of any action are low, API keys provide sufficient access control.
- Rate-limited services — if the API already enforces rate limits and the worst-case scenario is acceptable, adding an authorization layer may not be worth the complexity.
The decision comes down to consequences. If an agent misbehaving with an API key results in a large bill, a data breach, or an irreversible action, you need more than static credentials. If the worst case is a few unnecessary API calls, keys are probably fine.
When You Need OpenLeash
Per-action authorization becomes essential when agents operate in higher-stakes environments:
- Agents spending money — any agent with access to payment APIs, marketplace purchases, or subscription management needs spending controls that API keys can't provide.
- Agents with external communication — sending emails, posting messages, or contacting third parties on behalf of a user requires authorization beyond "has email API access."
- Regulated actions — healthcare, finance, and legal domains often require proof that each action was explicitly authorized, not just that the system had credentials.
- Multi-agent systems — when multiple agents collaborate, each agent's actions need independent authorization. A shared API key across agents provides no isolation or accountability.
- Counterparty verification — if the service receiving the agent's request needs to verify that the agent's owner actually authorized it, API keys offer no mechanism for that. Cryptographic proof tokens do.
In these scenarios, OpenLeash sits between the agent and the action — not replacing the API key (the agent still needs credentials to call the API) but adding a policy layer that governs which actions are permitted, under what conditions, with what proof.
Learn More
Explore how OpenLeash compares to other authorization models: OpenLeash vs OAuth covers how OpenLeash complements token-based delegation. For foundational concepts, read about AI agent authorization, AI agent guardrails, human-in-the-loop controls, and PASETO proof tokens. Or jump into the documentation to start building.