Give your agent a wallet
An agent key is an API key for a bot, app or AI agent that spends money on its own. It works like any other MartLLM key, on every model, the API and the MCP server, and you decide how much it may spend:
- Allowance: the most it may spend a day or a month.
- Most per call (optional): no single call may cost more than this.
- Ask me first above (optional): a call that could cost more than this waits until you
approve it.
0means every call asks.
Make one in Settings → Team, under Agents: give it a name and its limits, press Make agent, and copy the key. It is shown once.
What the agent sees
Before a call runs, MartLLM works out the most it can cost (the same amount it holds from your balance) and checks it against the agent's limits. Nothing is sent to a model and nothing is charged when a limit stops it.
| HTTP | code | what happened | what the agent should do |
|---|---|---|---|
| 402 | approval_required |
The call can cost more than the agent may spend without asking. We asked you to approve it. | Wait, then send the same call again. |
| 402 | agent_call_cap |
The call can cost more than the most per call. | Use a cheaper model or a lower max_tokens. |
| 402 | key_spend_cap_exceeded |
The allowance for today or this month is used up. | Wait for it to start again, or ask you to raise it. |
| 402 | approval_denied |
You said no. | Do not send it again. |
| 402 | approval_pending |
The approval it named is still waiting for you. | Try again later. |
| 402 | approval_used / approval_expired / approval_too_small / approval_unknown |
The approval it named can't be used for this call. | Send the call without it to ask again. |
| 402 | approval_in_use |
The approval is letting another call through right now. | Wait for that call to finish. |
An approval_required answer looks like this:
{"error": {"type": "insufficient_quota", "code": "approval_required",
"message": "This call can cost up to $2.40, more than the $1.00 this agent may spend without asking. We asked the account owner to approve it at https://martllm.com/dashboard/account?approval=6f1c0e8e-…#team . Once they approve, send the same call again (or add the header X-MartLLM-Approval: 6f1c0e8e-…). The request expires at 2026-11-27 14:05 UTC."}}
Approving a call
You, and the account's admins, get an email listing what your agents asked for, with a button to the Team page. Approve or deny it there. Approving from the email alone is not possible, so a forwarded email can't spend your money.
Once you approve, the agent sends the call again and it goes through. It finds the approval by itself, on the same key and model, for any call that costs up to the approved amount. To name it, send the header:
X-MartLLM-Approval: 6f1c0e8e-1111-4c2b-9d3a-0a0b0c0d0e0f
- One approval, one charged call. After a call it let through is charged, the approval
is used up. Sending the same approval again is refused with
approval_used. - A call that failed costs nothing and keeps the approval. If the call ends with nothing charged, the agent can send it again with the same approval.
- It expires. A request nobody answers ends after 24 hours, and an approved one must be used within 24 hours of approving it.
- Asking again for the same call while you haven't answered doesn't make a second request. One agent can have at most 20 requests waiting.
Over MCP
An agent key works as the key of the MCP server. A refused tool call comes back
as an error result with the same code and message, so the agent can tell you what it is
waiting for. After you approve, the same tool call goes through. An MCP client can also
send X-MartLLM-Approval on its connection.
Who can do what
- Anyone on the account can make agents. A member sees and changes only the agents they made, and those count toward their monthly budget too.
- Only the owner and admins can approve or deny.
- The allowance, the most per call and each key's own limits all apply: whichever is reached first stops the call.
No account? Pay per request
An agent can also pay for each request from its own crypto wallet, with no account and no key, using x402. An agent key is the simpler choice when you want one bill, limits you can change, and calls you approve.
From code
The dashboard routes are behind your signed-in session (not an API key):
| Route | What it does |
|---|---|
GET /api/v1/agents |
Your agents with their limits and spend today and this month, and their requests |
POST /api/v1/agents |
{"name", "allowance_usd", "allowance_window": "daily"|"monthly", "call_cap_usd", "approve_above_usd"} makes one; the answer has the key, once |
PUT /api/v1/agents/{key_id}/limits |
The same limits, without name (null = none) |
POST /api/v1/team/approvals/{id}/approve |
Approve (owner and admins) |
POST /api/v1/team/approvals/{id}/deny |
Deny (owner and admins) |