SKIP TO CONTENT
AI AGENTS6 minAgents in Production / Ep. 13 · Stage 13-1

AI Agent Login Without an API Key: Short-Lived Access

Your agent holds an API key that can stay valid for months, for anyone who copies it. What should it hold instead?

XIN
Pixel-art night scene: a small robot at a glowing kiosk trades one big brass master key for a tiny teal key tied to its wrist by a light thread, while a sand timer above the slot runs down.

IN 30 SECONDS

Agent authentication without an API key is a setup where the agent proves who it is with its own identity, then gets a token that opens one API for a few minutes. A pasted key usually lasts for months and opens far too much.

KEY TAKEAWAYS · 3

  • A pasted, long-lived API key is the wrong credential for an AI agent: it can leak into logs, reaches every sub-agent and sits one prompt injection from the model.
  • Give each agent its own platform identity, then trade it for a token that opens one API for minutes.
  • An IETF draft on agent identity says the model must not reach the agent’s credentials. It is an Internet-Draft and can still change.
On this page

Why a pasted API key is the wrong credential for an agent

IN SHORT A pasted API key hands your longest-lived secret to the most exposed process in your stack.

WORDS TO KNOW

API key
A long secret string that lets whoever sends it use an API account. Anyone who copies it can use it too.
Access token
A pass an API accepts instead of a password. It grants limited rights, and in this episode it expires within minutes.
Workload identity
An identity the platform gives a running program, through a credential it issues. No person pastes it in.

Someone pastes an API key A long secret string that lets whoever sends it use an API account. Anyone who copies it can use it too. See the glossary into an environment variable. The agent shares it with every sub-agent, the helper agents it hands parts of the job to. That key usually lives for months and carries far more rights than one task needs.

Put it in an agent and three things go wrong at once:

  • the key can end up in logs and crash dumps;
  • every sub-agent inherits all of it;
  • the model is one prompt injection away from reading it back out.

IN PLAIN WORDS

A prompt injection is an attack that slips instructions to the model, for example hidden in a web page or an email the agent reads. Short-lived, narrow tokens limit what it can reach, not the attack itself.

TWO WAYS TO GIVE AN AGENT ACCESS

The pasted key

One long-lived secret in an environment variable, shared by the main agent and every sub-agent. It works on every endpoint the account can reach, for whoever copies it.

The exchanged token

Issued per sub-agent from its own identity. It opens one API, with part of the parent’s rights, for five minutes. Tied to a key the agent holds. Never visible to the model.
Illustrative. The right side is the design this episode builds.

That last point isn’t my idea. The IETF, which writes internet standards, makes it a rule in its working-group draft on agent identity, an Internet-Draft that can still change:

The Large Language Model MUST NOT have access to an agent’s credentials or to credentials that may be needed to access tools and services.

draft-ietf-wimse-aims-00

So the token lives in the code that makes the HTTP call, not in the model’s context.

In least privilege for agents that move money I argued for short-lived credentials scoped to one task, and stopped at the principle.

Coming up next: So what does an agent carry instead of a key?

How should an AI agent authenticate when no user is present?

IN SHORT Start from identity, not from a secret: the platform names the agent, then the authorization server turns that name into a narrow token.

A headless agent runs with nobody at the screen, so no one can click “allow”. It needs its own Workload identity An identity the platform gives a running program, through a credential it issues. No person pastes it in. See the glossary, given by the platform it runs on.

The credential that proves it is short-lived. Prefer a format tied to a key made on the workload, such as an X.509-SVID (a certificate) or a WIMSE workload identity token. The IETF draft calls JWT-SVIDs “short-lived bearer credentials”: whoever holds one can use it.

THE FLOW I’D BUILD

Sequence diagram: 5 participants: Workload platform, Orchestrator agent, Fetcher sub-agent, Authorization server, Ledger APISequence diagram: 5 participants: Workload platform, Orchestrator agent, Fetcher sub-agent, Authorization server, Ledger API. Step 1: Workload platform to Orchestrator agent, Issue a short-lived identity. Step 2: Orchestrator agent to Authorization server, Get a token for its own identity. Step 3: Workload platform to Fetcher sub-agent, Issue the sub-agent its own identity. Step 4: Fetcher sub-agent to Authorization server, Trade: parent token plus own identity. Step 5: Authorization server to Fetcher sub-agent, Narrower token, five minutes, tied to its key. Step 6: Fetcher sub-agent to Ledger API, Call with the token and a fresh proof.WORKLOAD PLATFORM >ORCHESTRATOR AGENTIssue a short-lived identityORCHESTRATOR AGENT >AUTHORIZATION SERVERGet a token for its ownidentityWORKLOAD PLATFORM > FETCHERSUB-AGENTIssue the sub-agent its ownidentityFETCHER SUB-AGENT >AUTHORIZATION SERVERTrade: parent token plus ownidentityAUTHORIZATION SERVER >FETCHER SUB-AGENTNarrower token, five minutes,tied to its keyFETCHER SUB-AGENT > LEDGERAPICall with the token and afresh proof

Step 1. Identity. The platform gives the orchestrator a short-lived identity credential, tied to a key made on the workload. No person copies it.

Pick a step to see it move
  1. Identity The platform gives the orchestrator a short-lived identity credential, tied to a key made on the workload. No person copies it.
  2. Own token The orchestrator proves that identity and gets its own access token.
  3. Sub-agent identity The platform gives the fetcher its own identity too, so the logs can name the process that acted.
  4. Exchange The fetcher sends the parent token plus its own identity, and asks for one scope on one API, with a DPoP proof signed by its private key.
  5. Narrow token The server checks the request and returns a token that lasts at most five minutes and only works with the fetcher’s key.
  6. Call The fetcher calls the ledger API with the token and a fresh proof. The API checks the signature, expiry, target, scope and key.
An orchestrator (the main agent that hands out the work) starts a fetcher sub-agent, with no user present. Only the authorization server decides the scope; the agents only ask.

The sub-agent has its own identity, so the audit trail can say which process acted, not just “the service account did it”. And it never sees the orchestrator’s credential, only a token meant for exchange.

ADAM says: Think of a hotel desk that codes a card for one room, instead of a master key passed around. Unlike a room card, these tokens also need the agent’s private key, so a copied one opens nothing while that key stays safe.

If you only have one agent, drop the sub-agent exchange step and keep the rest.

ITEM GET

Identity first, then a narrow token

The platform names the agent. The authorization server turns that name into a token for one API that lasts minutes.

STAGE CLEAR

What you now know

  • Why a pasted key is risky in an agent: it can last for months, reaches every sub-agent and can leak.
  • What replaces it: a platform identity per agent, traded for a token that opens one API for minutes.
  • Where the token lives: in the code that makes the call, never in the model’s context.

Check yourself

Tap or click a question to see the answer.

Your agent works alone, with no sub-agents. Do you still need a workload identity?

Yes. Only the sub-agent exchange step goes. The agent still proves its own identity and gets a short-lived token for one API.

Next stage:How does a sub-agent get fewer rights than the agent that started it?6 min
Adam Boudjemaa
Adam Boudjemaa

Web3 x AI engineer, former CTO of Integra. Named author (1 of 5) of ERC-3643, first author of ERC-6960, co-author of ERC-7410, and co-author of ERC-8203, which is still a draft.

Have a project to ship or a role to fill?

Discuss your project or role

My work at the web3 x AI intersectionOpen-source tools I build

Follow the engineering notes

Get new articles on production AI and smart contracts by email.