How an AI agent gets an API key with Sign-In with Ethereum
How can an autonomous agent create its own API key without a browser?
Get a nonce from GET /v1/auth/nonce, sign the exact Sign-In with Ethereum (EIP-4361) message with the owner wallet, and POST /v1/auth/keys with the message and signature. The response holds the API key (oct_live_…) once; the account is created on first use.
Example with viem (TypeScript)
Create a key with viem
import { privateKeyToAccount } from 'viem/accounts'
import { createSiweMessage } from 'viem/siwe'
const ORIGIN = '{{origin}}'
const owner = privateKeyToAccount(process.env.OWNER_PRIVATE_KEY as `0x${string}`)
const { nonce, issued_at } = await fetch(`${ORIGIN}/v1/auth/nonce`).then((res) => res.json())
const message = createSiweMessage({
domain: new URL(ORIGIN).host,
uri: ORIGIN,
address: owner.address,
chainId: 4663,
version: '1',
nonce,
statement: 'Create an Octio API key',
issuedAt: new Date(issued_at),
})
const signature = await owner.signMessage({ message })
const res = await fetch(`${ORIGIN}/v1/auth/keys`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ message, signature, name: 'research-agent' }),
})
const { secret } = await res.json() // the API key, shown onceRules that trip agents up
- Use the server’s issued_at as Issued At, copied verbatim, so a skewed local clock is not rejected.
- Lines end in LF, with no newline after the Issued At line: the server accepts only the exact form viem createSiweMessage writes.
- Use the checksummed (EIP-55) address.
- Use the same owner wallet for funding: deposits are matched by the sender address.
- Up to 10 active keys per account. A lost key cannot be recovered, only revoked and replaced.
A key that can also publish APIs needs the statement “Create an Octio API key that can publish”. The full message format is in llms.txt and the docs.
FAQ
What is Sign-In with Ethereum?
EIP-4361, a standard text message a wallet signs to prove it controls an address. Octio uses it so an agent can create its own key with no browser and no password.
Does signing the message cost gas or move funds?
No. It is an off-chain signature of a text message.
Can a person create the key instead?
Yes. Connect the owner wallet on the account page and create a key there.
Updated 2026-11-16.