Guides
Authentication
Wallet sign-in, API keys, and how to get a key from a script without a browser.
Live
Send your key as a bearer token:
Authorization: Bearer fr_...
A key belongs to one FLOP wallet. There are no accounts, emails or passwords. Your wallet signs a one-time login message and the server gives you a key for that wallet. Signing the message is free and is not a transaction.
In the browser
Go to the account page, connect a wallet extension and press Sign and create key. The key is shown once. You can keep it in that browser for the playground.
From a script or an agent
Two calls. The challenge is a short string that expires.
curl -X POST https://api.floprouter.com/v1/auth/challenge \ -H "Content-Type: application/json" \ -d '{"address": "5YourWalletAddress..."}' # {"challenge": "...", "expires_at": "..."}
Sign the challenge string's UTF-8 bytes with the wallet's sr25519 or ed25519 key, then exchange the signature for a key:
curl -X POST https://api.floprouter.com/v1/auth/keys \ -H "Content-Type: application/json" \ -d '{"address": "5YourWalletAddress...", "challenge": "...", "signature": "0x..."}' # {"key": "fr_...", "address": "5YourWalletAddress..."}
The challenge is a few lines of text naming your address, the network and an expiry. It states that signing does not move funds. The same flow in Node with polkadot-js:
import { Keyring } from "@polkadot/keyring"; import { cryptoWaitReady } from "@polkadot/util-crypto"; import { stringToU8a, u8aToHex } from "@polkadot/util"; const API = "https://api.floprouter.com"; await cryptoWaitReady(); const pair = new Keyring({ type: "sr25519" }).addFromUri(process.env.FLOP_WALLET_URI); const post = (path, body) => fetch(API + path, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(body) }).then((r) => r.json()); const { challenge } = await post("/v1/auth/challenge", { address: pair.address }); const signature = u8aToHex(pair.sign(stringToU8a(challenge))); const { key } = await post("/v1/auth/keys", { address: pair.address, challenge, signature }); console.log(key);
Browser wallet extensions wrap the bytes as <Bytes>...</Bytes> before signing. The website signs that way; a script usually signs the bare bytes.
The response includes the key's id and its payer_mode.
Payer mode of a key
A new key starts in grant mode: your wallet pays on chain, which needs the one-time grant. Until you sign it, chat requests with that key fail with 402 grant_required. Either sign the grant on the account page, or switch the key to credit so the router pays from your prepaid balance:
curl -X PATCH https://api.floprouter.com/v1/auth/keys/<id> \ -H "Authorization: Bearer $FLOPROUTER_API_KEY" \ -H "Content-Type: application/json" \ -d '{"payer": "credit"}'
See payer modes.
List and revoke keys
curl https://api.floprouter.com/v1/auth/keys -H "Authorization: Bearer $FLOPROUTER_API_KEY" curl -X DELETE https://api.floprouter.com/v1/auth/keys/<id> -H "Authorization: Bearer $FLOPROUTER_API_KEY"
Both act on the wallet that owns the key you send. A wallet can hold a limited number of active keys; past it, creating one fails with 409 too_many_keys.
Without a key
The directory endpoints (/v1/miners, /v1/models, /v1/stats, /health) need no key. Chat completions need one, unless the server runs an anonymous demo mode. That mode is off unless the operator turns it on; it is limited to devnet, has a small rate limit, and the router pays. Not live yet
Keep keys secret
A key can spend your balance and, with a grant, open sessions paid by your wallet within the grant's limits. Do not put it in front-end code or public repositories. Revoke a key you no longer use.