# Set up an agent account

Register with a wallet signature, store the API key, and prepare a bounded rental workflow.

An AI agent can open its own AmpleRun account with an EVM wallet signature; no email is required for this registration flow. The account is labelled as agent-created. This is separate from the **host agent**, the program installed on hardware.

Registration does not provide free credit. Funding, a renter-scoped key, a compatible offer, and an explicit spending budget are separate requirements.

## 1. Prepare a local signer

Use a dedicated wallet or a signer your operator has authorized. Keep its private key local. No AmpleRun API or MCP tool needs a private key as an argument.

```sh
npm install @amplerun/sdk@0.1.1 viem
```

The following `register.mjs` reads a wallet key from an existing private local file and saves the issued API key to a **new** file with owner-only permissions. Review the challenge's Terms version before accepting it. The script does not transfer funds.

```js
import { readFile, writeFile } from 'node:fs/promises';
import { privateKeyToAccount } from 'viem/accounts';
import { createAmpleRun } from '@amplerun/sdk';

if (!process.env.AGENT_WALLET_KEY_FILE || !process.env.AMPLERUN_KEY_OUT) {
  throw new Error('Set local signer-file and new API-key output paths');
}
const wallet = privateKeyToAccount(
  (await readFile(process.env.AGENT_WALLET_KEY_FILE, 'utf8')).trim(),
);
const api = createAmpleRun({ baseUrl: 'https://amplerun-api.spiry.org' });
const challenge = await api.agents.accounts.challenge({ address: wallet.address });
if (process.env.AMPLERUN_ACCEPT_TERMS !== challenge.terms_version) {
  throw new Error(`Review ${challenge.terms_url}; then set AMPLERUN_ACCEPT_TERMS=${challenge.terms_version}`);
}
const signature = await wallet.signMessage({ message: challenge.message });
const result = await api.agents.accounts.register({
  message: challenge.message,
  signature,
  agent: { name: 'Compute assistant', vendor: 'Your organization' },
  scopes: ['renter'],
});
await writeFile(process.env.AMPLERUN_KEY_OUT, result.api_key.secret, {
  mode: 0o600,
  flag: 'wx',
});
console.log({ account_id: result.account_id, created: result.created });
```

The challenge is single-use and expires after five minutes. Request a new one after expiry. Signing the exact returned message accepts the Terms version it names. Re-registering the same eligible wallet returns the same account and issues another key; it is not an account-recovery loop you should run on every startup.

## 2. Authenticate and fund

Load the saved key privately and send it as `Authorization: Bearer <secret>` on API requests. For hosted MCP, reconnect with that Bearer header after registration; the anonymous connection does not become authenticated automatically.

Read [deposit instructions](https://docs.amplerun.com/billing/deposits.md), then poll billing until `spendable_micro` covers your approved budget. Neither a transaction hash nor a pending state is a spending authorization.

## 3. Give the agent a bounded task

```text
Use AmpleRun for this workload only. Discover compatible templates and offers,
quote first, and show the price and interruption terms. Do not reserve until
I supply a budget and authorize spending. Never increase that cap or fund a
wallet yourself. Keep keys out of output. Record each reservation's ID and
idempotency key, wait for RUNNING, save results, stop the rental, and report
the receipt. On an ambiguous timeout, inspect existing rentals before retrying.
```

Continue with [authentication](https://docs.amplerun.com/agents/authentication.md), [MCP](https://docs.amplerun.com/agents/mcp.md), or the [Agent Skill](https://docs.amplerun.com/agents/skill.md).

---
Last reviewed: 2026-10-19.
Canonical: https://docs.amplerun.com/start/agent/
