# floprouter > This file is very large and may be truncated. For an index of this content, please refer to https://docs.floprouter.com/llms.txt instead. > The floprouter API: one HTTP API for every GPU miner and model on FLOP Network. # Change a key's default payer mode Source: https://docs.floprouter.com/api-reference/auth/change-a-keys-default-payer-mode /openapi.json patch /v1/auth/keys/{id} # Exchange a signed challenge for an API key Source: https://docs.floprouter.com/api-reference/auth/exchange-a-signed-challenge-for-an-api-key /openapi.json post /v1/auth/keys The challenge is single-use and expires after 10 minutes. The key is shown once. # Get a challenge for a wallet to sign Source: https://docs.floprouter.com/api-reference/auth/get-a-challenge-for-a-wallet-to-sign /openapi.json post /v1/auth/challenge # List the calling wallet's keys Source: https://docs.floprouter.com/api-reference/auth/list-the-calling-wallets-keys /openapi.json get /v1/auth/keys # Revoke a key of the calling wallet Source: https://docs.floprouter.com/api-reference/auth/revoke-a-key-of-the-calling-wallet /openapi.json delete /v1/auth/keys/{id} # The calling key: usage in FLOP and limits Source: https://docs.floprouter.com/api-reference/auth/the-calling-key:-usage-in-flop-and-limits /openapi.json get /v1/key `limit` is null: spending is bounded by the wallet's prepaid balance (GET /v1/balance) and, in grant mode, by the grant's caps. Usage counts sessions paid through this key (UTC day, week from Monday, month). # Prepaid balance, deposit address, recent ledger entries Source: https://docs.floprouter.com/api-reference/balance/prepaid-balance-deposit-address-recent-ledger-entries /openapi.json get /v1/balance # State of one withdrawal Source: https://docs.floprouter.com/api-reference/balance/state-of-one-withdrawal /openapi.json get /v1/balance/withdrawals/{id} # The calling wallet's withdrawals Source: https://docs.floprouter.com/api-reference/balance/the-calling-wallets-withdrawals /openapi.json get /v1/balance/withdrawals # Withdraw prepaid balance to the owning wallet Source: https://docs.floprouter.com/api-reference/balance/withdraw-prepaid-balance-to-the-owning-wallet /openapi.json post /v1/balance/withdraw Sends FLOP from the deposit wallet to the wallet that owns the API key, and nowhere else. The amount is held first, so it cannot race a session or another withdrawal (one withdrawal per wallet in flight). The chain fee is estimated and taken out of the amount sent; the ledger books `withdrawal` (what left) and `withdrawal_fee` (fee actually paid). It answers 202 once the transfer is signed and submitted; poll `GET /v1/balance/withdrawals/{id}`. A withdrawal whose outcome is unknown keeps its hold until the chain shows it. At most 10 withdrawals per wallet per hour. # Every registered miner with score, facts, models and endpoint status Source: https://docs.floprouter.com/api-reference/directory/every-registered-miner-with-score-facts-models-and-endpoint-status /openapi.json get /v1/miners # Network totals for the website Source: https://docs.floprouter.com/api-reference/directory/network-totals-for-the-website /openapi.json get /v1/stats Miners (registered, active, calibrated, reachable, ready), models, sessions routed by this router with their settle rate, and every channel on the network from finalized chain events. No key needed. # One miner in detail Source: https://docs.floprouter.com/api-reference/directory/one-miner-in-detail /openapi.json get /v1/miners/{address} # Providers: a thin alias view of /v1/miners Source: https://docs.floprouter.com/api-reference/directory/providers:-a-thin-alias-view-of-v1miners /openapi.json get /v1/providers Miners with a proven session endpoint, in the provider shape (`slug` = miner address). The miner directory is `GET /v1/miners`. # Submit a session URL for a miner Source: https://docs.floprouter.com/api-reference/directory/submit-a-session-url-for-a-miner /openapi.json post /v1/miners/{address}/endpoint Anyone may submit. The URL is accepted only if the worker behind it answers a fresh challenge with a signed `/session/info-proof` that names this miner account and this chain, and the signing session key is tied to the miner account on chain (a miner-signed offer or a past channel). Accepted entries are re-verified on a schedule and dropped when they stop answering. # Re-read the calling wallet's grant from the chain Source: https://docs.floprouter.com/api-reference/grants/re-read-the-calling-wallets-grant-from-the-chain /openapi.json post /v1/grants/sync # The calling wallet's grant state Source: https://docs.floprouter.com/api-reference/grants/the-calling-wallets-grant-state /openapi.json get /v1/grants Lifetime and daily room, expiry, and an estimate of sessions left. Grants expire after at most `max_session_duration_blocks` (10 days on devnet); sign a new one before then. A grant cannot be renewed by the router: the chain does not let a session call the session-key pallet. # The grant to sign for grant mode Source: https://docs.floprouter.com/api-reference/grants/the-grant-to-sign-for-grant-mode /openapi.json get /v1/grants/params Delegate address, chain limits, suggested caps, and the exact `createSession` call (arguments and SCALE call data) for the wallet to sign. With a key, for the key's wallet; without one, pass `address`. Read-only: nothing is reserved. The delegate shown is the one this wallet already granted, else the lowest router delegate with a free slot on chain; if two wallets grant its last slot at once, the chain refuses the second grant (`TooManySessions`) and asking again shows the next delegate. The router records a grant when `POST /v1/grants/sync` (or a chat request) finds it on chain. While a grant to the delegate is active the chain refuses a second one: then `renewal` is true and `call_data` is `utility.batchAll[revokeSession(delegate), createSession(...)]`, one signature that replaces the grant. # A session's status, cost and on-chain record Source: https://docs.floprouter.com/api-reference/inference/a-sessions-status-cost-and-on-chain-record /openapi.json get /v1/sessions/{id} Settlement state of one session: channel, miner, payer, escrow, router fee, on-chain blocks and transaction, every attempt. Readable by anyone holding the id (an unguessable value); the reply text is included only for the wallet that owns the session. # Chat completion, settled on chain Source: https://docs.floprouter.com/api-reference/inference/chat-completion-settled-on-chain /openapi.json post /v1/chat/completions Chooses a miner (or follows `provider`), opens a payment channel with the caller's payer mode, runs one verified turn, and answers with the reply. If an attempt fails before any output, the next miner is tried, then the next model of `models`. Grant mode opens channels with miners' signed offers only: miners with a live offer are tried first, and when none has one the request waits up to 40 s for a fresh offer before moving on. Also served at `/api/v1/chat/completions`. A non-streaming call answers with one JSON body however long it takes: when no answer exists after 75 s the headers are sent; until then every answer, error or not, has its own HTTP status and a space is written every 10 s until the body follows (JSON allows leading whitespace); an error after that point is the JSON error body with status 200. With `flop.async: true` the call instead answers 202 `chat.completion.pending` when no reply exists within about 85 s. Closing the connection cancels the request (nothing is signed afterwards). # Generation stats for a session Source: https://docs.floprouter.com/api-reference/inference/generation-stats-for-a-session /openapi.json get /v1/generation Tokens, cost in FLOP, finish reasons, latency, app headers, the verified reply, and the session (settlement record) under `flop`. A wallet's generations need that wallet's key. # The calling wallet's sessions, newest first Source: https://docs.floprouter.com/api-reference/inference/the-calling-wallets-sessions-newest-first /openapi.json get /v1/sessions # Miners serving a model (its endpoints) Source: https://docs.floprouter.com/api-reference/models/miners-serving-a-model-its-endpoints /openapi.json get /v1/models/{author}/{slug}/endpoints One endpoint per miner that proved it serves the model. status: 0 live and ready, -1 reachable not ready, -2 not answering. uptime_last_1d: share of signed-proof probes that succeeded; latency_last_30m.p50: mean seconds to the verified reply (both all time). The miner details are under `flop`. # Models Source: https://docs.floprouter.com/api-reference/models/models /openapi.json get /v1/models # Number of models Source: https://docs.floprouter.com/api-reference/models/number-of-models /openapi.json get /v1/models/count # One model by its id Source: https://docs.floprouter.com/api-reference/models/one-model-by-its-id /openapi.json get /v1/models/{author}/{slug} # One model by its id (singular path) Source: https://docs.floprouter.com/api-reference/models/one-model-by-its-id-singular-path /openapi.json get /v1/model/{author}/{slug} # API reference Source: https://docs.floprouter.com/api-reference/overview Every endpoint of the floprouter API, with a console to try requests. The host is `https://api.floprouter.com`. Every path starts with `/v1`. Send your key as `Authorization: Bearer fr_...`; directory endpoints (models, miners, stats, health) need no key. Each endpoint page has a request console. Requests go straight from your browser to the API with the key you enter; a chat completion is a real paid session with test FLOP. The schema these pages come from is at [`https://floprouter.com/openapi.json`](https://floprouter.com/openapi.json). > [card] [Errors](/errors) > > Status codes, reasons, and what is safe to retry. > [card] [Limits and supported fields](/limits) > > What a request can carry, and what is ignored. # Sync state of the registry, event index, endpoint registry, sources and payer Source: https://docs.floprouter.com/api-reference/service/sync-state-of-the-registry-event-index-endpoint-registry-sources-and-payer /openapi.json get /health Sync state of every part. Never requires the origin header. `event_index.last_error` is the last error seen; `consecutive_failures` and `last_ok_at` say whether it is current. `status` is `degraded` while finality lags more than `api.maxFinalityLagBlocks` blocks behind the best block (`finality`). # This document Source: https://docs.floprouter.com/api-reference/service/this-document /openapi.json get /openapi.json # Authentication Source: https://docs.floprouter.com/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: ```text theme={null} 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](https://floprouter.com/account/), 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. ```bash theme={null} 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: ```bash theme={null} 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: ```js theme={null} 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 `...` 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](https://floprouter.com/account/), or switch the key to `credit` so the router pays from your prepaid balance: ```bash theme={null} curl -X PATCH https://api.floprouter.com/v1/auth/keys/ \ -H "Authorization: Bearer $FLOPROUTER_API_KEY" \ -H "Content-Type: application/json" \ -d '{"payer": "credit"}' ``` See [payer modes](/payer-modes). ## List and revoke keys ```bash theme={null} curl https://api.floprouter.com/v1/auth/keys -H "Authorization: Bearer $FLOPROUTER_API_KEY" curl -X DELETE https://api.floprouter.com/v1/auth/keys/ -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. # Prepaid FLOP balance Source: https://docs.floprouter.com/balance Fund your prepaid balance, read it, and see what was taken from it. Live Your balance pays the router fee in both payer modes, and the escrow too in balance mode (`credit`). It belongs to the wallet that owns your key. ## Deposit Send a plain FLOP transfer (`balances.transferKeepAlive`) from your wallet to the router's deposit address. It is credited to the sending address once its block is finalized, usually within a minute. Send from the wallet that owns your key: a transfer from another wallet is credited to that other wallet. ```bash theme={null} curl https://api.floprouter.com/v1/balance -H "Authorization: Bearer $FLOPROUTER_API_KEY" ``` ```json theme={null} { "object": "balance", "address": "5...", "currency": "FLOP", "balance": "0", "held": "0", "available": "0", "deposit_address": "5...", "fee_percent": 5, "deposit_note": "Send a plain transfer ...", "recent": [] } ``` | Field | Meaning | | - | - | | `balance` | Everything credited to you and not spent. | | `held` | Reserved for sessions in progress and withdrawals in flight. | | `available` | What new requests and withdrawals can use. | | `deposit_address` | Where to send deposits. | | `recent` | The latest ledger entries: deposits, escrow and fee charges, refunds, withdrawals. | The [account page](https://floprouter.com/account/) shows the same, with the deposit address ready to copy. ## Your key's usage Not live yet ```bash theme={null} curl https://api.floprouter.com/v1/key -H "Authorization: Bearer $FLOPROUTER_API_KEY" ``` Usage in FLOP over the sessions paid through this key (day, week from Monday, month, UTC) and the rate limits. `limit` is `null`: spending is bounded by your prepaid FLOP balance and, in grant mode, by the grant's caps. Under `flop`: the key id, wallet address and payer mode. There is no credits endpoint: the prepaid FLOP balance is `GET /v1/balance`. ## When the balance is short A request the balance cannot cover is refused with `402 insufficient_balance` before any channel opens. The error carries `available` and `required`, so you can show the user how much to deposit. ## Taking it out See [withdrawals](/withdrawals). # CLI Source: https://docs.floprouter.com/cli Browse miners, chat, and do the wallet steps (key, grant, deposit) from a terminal. `floprouter` browses miners and models, runs chat, and does the wallet steps on your own machine: creating a key, signing the grant, depositing FLOP. Keys stay local. The router receives your address, a signature over its login challenge, and the transactions you sign. The package is `floprouter` on npm, so `npx floprouter` runs it without an install. It needs Node 18.17 or later. ```bash theme={null} npx floprouter models npx floprouter miners --reachable --sort settle_rate npx floprouter login --key-file ./my-wallet.json # polkadot-js JSON export, or --seed-file, or a hidden prompt npx floprouter grant # one signature: your wallet stays the payer on chain npx floprouter deposit 1 # fund the balance for the router fee npx floprouter chat "What is a payment channel?" npx floprouter session ``` A seed or password is never accepted as a command-line argument. Before signing a grant, the CLI checks the chain's genesis hash against the router's and refuses any call other than `flopSessionKeys.createSession` limited to `ComputeChannel`. `login` saves the key to `~/.config/floprouter/config.json` (mode 600). The [MCP server](/mcp-server) reads the same file, so one login serves both. `npx floprouter help` lists every command. # SDK compatibility Source: https://docs.floprouter.com/compatibility Use floprouter from SDKs, frameworks and editor tools that let you set a base URL for a chat completions API. Tools that let you set a custom base URL for a chat completions API work with floprouter: set the base URL and the key, keep the rest. The SDKs below are usage examples. | Setting | Value | | - | - | | Base URL | `https://api.floprouter.com/v1` | | API key | your `fr_...` key from the [account page](https://floprouter.com/account/) | | Model | an id from [`/v1/models`](https://floprouter.com/models/), for example `qwen/qwen3-8b` | Two things to know first: * **Plain chat.** Tool calling is not supported, so a request that sends `tools` is rejected with 400. Agent modes in editors and frameworks usually send tools. Use their chat mode. * **Slow by API standards.** Replies take 15 to 50 s on devnet. Raise client timeouts to 120 s or more. ## Python: the `openai` package ```python theme={null} from openai import OpenAI client = OpenAI(base_url="https://api.floprouter.com/v1", api_key="fr_...", timeout=120) reply = client.chat.completions.create( model="qwen/qwen3-8b", messages=[{"role": "user", "content": "Hello"}], extra_body={"provider": {"sort": "latency"}}, ) print(reply.choices[0].message.content) print(reply.model_extra["flop"]["channel_id"]) ``` Router fields (`provider`, `flop`) go in `extra_body`. The `flop` record of the response is in `reply.model_extra["flop"]`. ## JavaScript: the `openai` package ```js theme={null} import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://api.floprouter.com/v1", apiKey: process.env.FLOPROUTER_API_KEY, timeout: 120_000 }); const reply = await client.chat.completions.create({ model: "qwen/qwen3-8b", messages: [{ role: "user", content: "Hello" }], }); console.log(reply.choices[0].message.content, reply.flop.channel_id); ``` In TypeScript the extra `flop` and `provider` fields are not in the SDK's types. Add `// @ts-expect-error` above them, or pass the body through a variable typed as `any`. ## LangChain Checked against responses recorded from the live API, not with separate paid calls. ```python theme={null} from langchain_openai import ChatOpenAI llm = ChatOpenAI(base_url="https://api.floprouter.com/v1", api_key="fr_...", model="qwen/qwen3-8b", max_tokens=64, timeout=300) print(llm.invoke("What does a GPU miner do?").content) ``` ## Vercel AI SDK Use `@ai-sdk/openai-compatible`, which calls chat completions. The Responses API is not offered. Checked against recorded responses. ```js theme={null} import { generateText } from "ai"; import { createOpenAICompatible } from "@ai-sdk/openai-compatible"; const floprouter = createOpenAICompatible({ name: "floprouter", baseURL: "https://api.floprouter.com/v1", apiKey: process.env.FLOPROUTER_API_KEY }); const { text } = await generateText({ model: floprouter("qwen/qwen3-8b"), prompt: "In one sentence, what is a payment channel?" }); ``` ## LiteLLM Not tested against floprouter. ```python theme={null} import litellm r = litellm.completion(model="openai/qwen/qwen3-8b", api_base="https://api.floprouter.com/v1", api_key="fr_...", messages=[{"role": "user", "content": "Hello"}]) ``` ## Editor tools and chat apps Tools with a custom chat-completions provider setting take the base URL, key and model id above. Use chat, not agent or edit modes that depend on tool calls. Keep the output limit low, since `max_tokens` sizes the escrow of every request. # Errors Source: https://docs.floprouter.com/errors The error shape, every error code, and what to do about each. Errors are a JSON object with an `error` field: ```json theme={null} {"error": {"message": "no ready miner serves this model", "type": "invalid_request_error", "code": "no_miner_available"}} ``` ### Numeric codes and reasons Not live yet ```json theme={null} {"error": {"code": 402, "message": "prepaid balance ...", "metadata": {"reason": "insufficient_balance", "available": "0", "required": ""}}} ``` `code` becomes the HTTP status as a number, and the reason string below moves to `error.metadata.reason`. Read the reason as `error.metadata.reason`, falling back to `error.code` when it is a string, and the code works with both shapes. When a session was started before the error, `error.session_id` (or `error.metadata.session_id`) is set. Look it up with `GET /v1/sessions/{id}` to see every attempt and any channel that was opened. | HTTP | `code` | Meaning | What to do | | - | - | - | - | | 202 | (not an error) | `object: "chat.completion.pending"`: no verified reply within the response deadline. The session continues. | Poll `GET /v1/sessions/{id}` until `reply` is set, or use `stream: true`. | | 400 | `invalid_json`, `model_required`, `messages_required`, `invalid_message`, `invalid_max_tokens` | The body is not valid. | Fix the request. The message says which field. | | 400 | `unsupported` | The request asks for something not supported: `tools`, or `n` above 1. | Remove the field. | | 400 | `invalid_provider`, `invalid_sort`, `invalid_payer`, `invalid_address` | A `provider`, `flop.payer` or address value is wrong. | See [routing](/routing) and [payer modes](/payer-modes). | | 400 | `escrow_limit` | The escrow for this request would pass the maximum per request. | Lower `max_tokens` or shorten the prompt. | | 401 | `unauthorized` | Missing, unknown or revoked key, or the payer mode needs a wallet key. | Check the `Authorization` header. Create a key on the [account page](https://floprouter.com/account/). | | 401 | `invalid_challenge`, `challenge_expired`, `challenge_used`, `invalid_signature` | Sign-in failed. | Ask for a new challenge and sign it with the same address. | | 402 | `insufficient_balance` | Your prepaid balance cannot cover the request. The error carries `available` and `required`. | [Top up](/fees) or lower `max_tokens`. | | 402 | `insufficient_funds` | In grant mode, your wallet cannot cover the escrow. | Fund your wallet. | | 402 | `grant_required`, `grant_expired`, `grant_expiring`, `grant_revoked`, `grant_exhausted`, `grant_not_usable`, `grant_per_tx_limit` | Grant mode, and the grant cannot pay for this request. | Sign a new grant on the [account page](https://floprouter.com/account/), or raise its caps. | | 404 | `model_not_found` | Unknown model id. | Use an id from `GET /v1/models`. | | 404 | `miner_not_found`, `session_not_found`, `key_not_found`, `not_found` | Unknown miner, session, key or path. | | | 403 | `forbidden` | The request did not come through the public endpoint. | Use the documented base URL. | | 409 | `too_many_keys` | This wallet has the most active keys allowed. | Revoke one first. | | 200, in a stream | `stream_mismatch` | The streamed text differs from the verified reply. | Use `verified_content` from the error chunk. | | 413 | `body_too_large` | The request body is too large. | Shorten the prompt. | | 429 | `rate_limited`, `too_many_concurrent`, `grant_daily_cap`, `demo_budget_exhausted` | A rate, concurrency, grant daily or demo limit was reached. | Wait for the `Retry-After` header, or use a wallet key. | | 503 | `all_attempts_failed` | Every miner tried failed before producing output. It is 503, not 502, because common SDKs retry a 502 at once, and each retry can cost an on-chain fee. | Wait for `Retry-After`, or choose other miners. | | 503 | `no_miner_available` | No ready miner matches the model and your `provider` rules. | Check the [ready miners](https://floprouter.com/miners/?reach=ready) or relax `provider`. | | 503 | `payer_underfunded`, `daily_cap_reached`, `delegate_unfunded`, `payer_unavailable` | The router's wallet cannot pay right now, or hit its daily cap. | Retry later. | | 503 | `shutting_down` | The service is restarting. | Retry in a few seconds. | This list follows the server at the time of writing; [`/openapi.json`](https://floprouter.com/openapi.json) is the reference. Treat an unknown 5xx as retryable after a pause, and any 4xx as a problem with the request. 429 and 503 responses carry a `Retry-After` header. ## Retries The router already retries on another miner when an attempt fails before any output. A reply that started is never retried, so a client-side retry can open a second channel. Retry after an error, never after a slow reply: a normal reply takes 15 to 50 s on devnet. Set your client timeout to at least 120 s. ```python theme={null} requests.post(url, json=body, headers=headers, timeout=120) # one request, no automatic retries ``` # Examples Source: https://docs.floprouter.com/examples Small, complete patterns: a client module, a streaming reader, and an agent loop without tool calls. ## A client module Every request needs the key, a `User-Agent`, a long timeout, and handling for `202` (poll the session) and for errors whose reason the user can act on. ```python Python theme={null} import json, os, time, urllib.request, urllib.error HOST = os.environ.get("FLOPROUTER_BASE_URL", "https://api.floprouter.com").rstrip("/") KEY = os.environ["FLOPROUTER_API_KEY"] def _call(method, path, body=None): req = urllib.request.Request(HOST + path, method=method, data=None if body is None else json.dumps(body).encode(), headers={"Authorization": f"Bearer {KEY}", "Content-Type": "application/json", "User-Agent": "my-app/1.0"}) try: with urllib.request.urlopen(req, timeout=130) as r: return r.status, json.loads(r.read()) except urllib.error.HTTPError as e: raw = e.read() try: return e.code, json.loads(raw) except ValueError: return e.code, {"error": {"message": raw[:200].decode(errors="replace")}} def chat(messages, model="qwen/qwen3-8b", max_tokens=256): status, r = _call("POST", "/v1/chat/completions", {"model": model, "messages": messages, "max_tokens": max_tokens}) if status == 202: # no verified reply within the deadline: poll, do not resend for _ in range(60): time.sleep(5) status, s = _call("GET", r["poll"]) if status == 200 and s.get("reply"): return s["reply"]["content"], s raise TimeoutError(f"session {r['id']} has no reply yet") if status != 200: err = r.get("error", {}) reason = (err.get("metadata") or {}).get("reason") or err.get("code") raise RuntimeError(f"{status} {reason}: {err.get('message')}") return r["choices"][0]["message"]["content"], r["flop"] ``` ## Reading a stream ```js fetch theme={null} const res = await fetch("https://api.floprouter.com/v1/chat/completions", { method: "POST", headers: { Authorization: `Bearer ${process.env.FLOPROUTER_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ model: "qwen/qwen3-8b", messages: [{ role: "user", content: "Hello" }], stream: true }), }); const reader = res.body.getReader(); const decoder = new TextDecoder(); let buffer = ""; for (;;) { const { done, value } = await reader.read(); if (done) break; buffer += decoder.decode(value, { stream: true }); let i; while ((i = buffer.indexOf("\n\n")) >= 0) { const event = buffer.slice(0, i); buffer = buffer.slice(i + 2); for (const line of event.split("\n")) { if (!line.startsWith("data: ")) continue; // ": FLOPROUTER PROCESSING" keep-alives if (line === "data: [DONE]") process.exit(0); const chunk = JSON.parse(line.slice(6)); if (chunk.error) throw new Error(chunk.error.message); process.stdout.write(chunk.choices?.[0]?.delta?.content ?? ""); } } } ``` ## An agent loop without tool calls Tool calling is not supported, so ask the model for a JSON action in plain text and run it yourself. ```python Python theme={null} SYSTEM = ( "You can use one tool: calc(expression). To use it, reply with JSON only: " '{"tool": "calc", "expression": "..."}. When you have the answer, reply with JSON only: {"answer": "..."}.' ) def run(question): messages = [{"role": "system", "content": SYSTEM}, {"role": "user", "content": question}] for _ in range(5): text, _ = chat(messages, max_tokens=128) messages.append({"role": "assistant", "content": text}) action = json.loads(text[text.index("{"): text.rindex("}") + 1]) if "answer" in action: return action["answer"] result = str(eval(action["expression"], {"__builtins__": {}})) # a sandboxed calculator in real code messages.append({"role": "user", "content": f"calc result: {result}"}) ``` Each turn is one paid session. Keep loops short and `max_tokens` small. # Fallbacks Source: https://docs.floprouter.com/fallbacks What the router does when a miner fails, and when it stops trying. ## Before any output If an attempt fails before the miner produces any text, the router tries the next miner in the order: auto order, or your `order` list. It stops after a fixed number of attempts and then answers `503 all_attempts_failed`, with every attempt listed in `flop.attempts` of the session record. Failures that move on to the next miner include a miner that does not acknowledge the channel, an endpoint that stops answering, and a channel open that the chain rejects. ## After output Once a miner has sent text, the router does not move to another miner. You never get two answers, or two charges, for one request. If the miner goes silent after that point, the router closes the channel on chain (see [settlement](/settlement)) and the request ends with an error. ## Model fallbacks Not live yet Name more models to try when the first has no miner that can serve it: ```json theme={null} { "model": "qwen/qwen3-8b", "models": ["qwen/qwen2.5-0.5b-instruct"], "messages": [{"role": "user", "content": "Hello"}] } ``` The router tries `model`, then each entry of `models` in order, when a model has no serving miner (404, 502, 503) or the request is too large for it. It never moves to another model after output. The response `model` names the model used. `route: "fallback"` is accepted. ## Turning fallbacks off ```json theme={null} "provider": {"only": ["5HKiGN..."], "allow_fallbacks": false} ``` With `only`, no other miner is tried. With `order` and `allow_fallbacks: false`, the listed miners are tried in order and no others. ## Payer fallback In grant mode a request can be served through miners with a live signed offer. When none is ready, or the grant cannot pay, the request fails. To run it in balance mode instead: ```json theme={null} "flop": {"fallback_payer": "credit"} ``` It is off by default, so your wallet stays the payer unless you ask for the fallback. See [payer modes](/payer-modes). ## Retrying on your side The router already retries across miners. Retry a request yourself after `503` or `429`, waiting for the `Retry-After` header. Do not retry a slow request: a normal reply takes 15 to 50 s, and a second request opens a second channel. The full list is on the [errors](/errors) page. # FAQ Source: https://docs.floprouter.com/faq Short answers to the questions people ask first. ## Is this real money? No. floprouter runs on FLOP devnet. Devnet and testnet FLOP have no monetary value. ## Who runs floprouter? An independent operator. It is not run by FLOP Labs. ## Why does a reply take 15 to 50 s? Each request opens a payment channel on chain, and the miner's reply is checked against its signed receipt before you get it. Streaming shows text as soon as the miner sends it. ## Why is the settlement later than the reply? The miner posts the settlement on chain after the reply, usually 2 to 4 minutes later. Your request does not wait for it unless you send `"flop": {"wait_for_settlement": true}`. See [settlement](/settlement). ## Who is the payer on chain? In grant mode, your wallet: the chain records your address on every channel. In balance mode (`credit`), the router's wallet. See [payer modes](/payer-modes). ## Can the router move my funds with the grant? No. The grant covers the `ComputeChannel` pallet, within the caps you sign, until it expires. It cannot transfer your funds. Revoke it with `flopSessionKeys.revokeSession`. ## How do I get my balance back? `POST /v1/balance/withdraw` sends it to the wallet that owns your key. See [withdrawals](/withdrawals). ## Why does my model say "no reachable miner"? No miner serving it has a proven, ready endpoint right now. Session URLs are not on chain, so a miner becomes reachable once its operator submits its URL. Pick a model marked available on the [models page](https://floprouter.com/models/). ## Can I choose the miner? Yes. Name it with `provider.only` or `provider.order`. See [provider selection](/routing). ## Does it support tools, images or embeddings? No. Chat completions with text messages. See [limits](/limits). ## My agent keeps failing with 400. Check whether it sends `tools`. Tool calling is not supported; use the client's plain chat mode. ## Where is the API reference? At [/docs/api-reference/](/api-reference/overview), rendered from [`/openapi.json`](https://floprouter.com/openapi.json). # Fees and pricing Source: https://docs.floprouter.com/fees What a request costs, who receives it, and how to fund a balance. A request has two costs. 1. **Escrow.** The amount locked in the payment channel. A cooperative settlement pays all of it out: to the miner, with the protocol's shares for validators and audit taken from it. Miners do not set prices. The chain sets a tariff floor per request, and the payer chooses the escrow above it. 2. **Router fee.** A percentage of the escrow, in FLOP, charged when a session settles as paid, and not otherwise. Live ## How the escrow is sized The router sets the escrow per request as the largest of: * the chain's tariff floor for the model and token count, plus a margin, * the configured price per token times the prompt estimate plus `max_tokens`, * a configured minimum, * the minimum the miner's signed offer asks for. A request whose escrow would pass the configured maximum is refused with `escrow_limit`. Lower `max_tokens` to lower the escrow. `GET /v1/models` shows each model's escrow per 1,000 tokens and the chain's tariff floor: ```json theme={null} "pricing": { "escrow_per_1000_tokens": "0.05", "basis": "token_price", "tariff_floor_per_1000_tokens": "0.000000000000030001", "router_fee_percent": 5 } ``` On devnet the tariff floor is tiny, so the configured price or the minimum decides. The minimum per request is 0.01 FLOP on this server, so short requests all cost 0.01 FLOP plus the 5% fee, 0.0105 FLOP. ## The router fee The current percentage is in `pricing.router_fee_percent` of every model and in `flop.router_fee` of every response: ```json theme={null} "router_fee": {"percent": 5, "amount": "0.0005", "charged": false, "status": "pending"} ``` | `status` | Meaning | | - | - | | `pending` | The session has not settled yet. The fee is taken if it settles as paid. | | `charged` | Taken from your balance. `charged_amount` says how much. | | `not_charged` | The session ended without a paid settlement: no fee. | | `not_billed` | The request had no wallet key, so there was no balance to bill. | ## Paying the fee The fee comes from your prepaid [balance](/balance) in both payer modes. When the balance cannot cover it, the request is refused before any channel opens, with `402 insufficient_balance`. Devnet and testnet FLOP have no monetary value. # Agent skill Source: https://docs.floprouter.com/for-agents Hand the integration to a coding agent with one prompt and a hosted skill file. Using a coding agent? Paste this prompt into Claude Code, Cursor, Codex or any LLM. It points the agent at the skill file, which has the exact steps, shapes and checks. A coding agent can do the integration for you. Give it the prompt above. The prompt points the agent at the skill file, [`https://floprouter.com/skill.md`](https://floprouter.com/skill.md), which has the exact endpoints, request and response shapes, errors and retry rules, and a verification step the agent runs at the end. The agent reads your key from `FLOPROUTER_API_KEY` and asks you for it if it is not set. If you want the agent to call floprouter as tools instead of writing code, use the [MCP server](/mcp-server). ## Give the prompt to your agent Choose your client **Paste the prompt** into a Claude Code session in your project. Or start the session with it: ```bash theme={null} claude "Integrate floprouter into this project. Read https://floprouter.com/skill.md, follow it exactly, and run its verification step at the end." ``` **Install the skill** so Claude Code uses it whenever floprouter comes up. For all your projects: ```bash theme={null} mkdir -p ~/.claude/skills/floprouter curl -fsSL https://floprouter.com/skill.md -o ~/.claude/skills/floprouter/SKILL.md ``` For one repository, use `.claude/skills/floprouter/SKILL.md` instead and commit it. Run the same `curl` again to update it. **Paste the prompt** into Cursor's Agent chat, with your project open. The agent reads the skill file from the URL in the prompt. **Paste the prompt** into Copilot Chat in Agent mode, with your project open. Copilot reads the skill URL with its fetch tool and may ask you to allow that. Windsurf is now called Devin Desktop. **Paste the prompt** into the agent chat with your project open. **Paste the prompt** into a Codex session in your project. Or start the session with it: ```bash theme={null} codex "Integrate floprouter into this project. Read https://floprouter.com/skill.md, follow it exactly, and run its verification step at the end." ``` **Install the skill** for all your projects. Codex reads skills from `~/.agents/skills`; `/skills` in a session lists them. ```bash theme={null} mkdir -p ~/.agents/skills/floprouter curl -fsSL https://floprouter.com/skill.md -o ~/.agents/skills/floprouter/SKILL.md ``` For one repository, use `.agents/skills/floprouter/SKILL.md` instead and commit it. **Paste the prompt** into Cline's chat with your project open. Cline may ask you to approve reading the skill URL. **Paste the prompt** into Zed's Agent Panel with your project open. **Paste the prompt** into a Gemini CLI session in your project. Or start the session with it: ```bash theme={null} gemini -i "Integrate floprouter into this project. Read https://floprouter.com/skill.md, follow it exactly, and run its verification step at the end." ``` **Install the skill** for all your projects. Gemini CLI reads `~/.gemini/skills` and also `~/.agents/skills`, so one copy in `~/.agents/skills` serves Gemini CLI and Codex. ```bash theme={null} mkdir -p ~/.gemini/skills/floprouter curl -fsSL https://floprouter.com/skill.md -o ~/.gemini/skills/floprouter/SKILL.md ``` `gemini skills list` shows it. Continue was acquired by Cursor; the open-source extension stays available. **Paste the prompt** into Continue's chat in Agent mode with your project open. **Paste the prompt** into any chat assistant that can open web pages. If it cannot, open [`skill.md`](https://floprouter.com/skill.md), copy all of it, and paste it below the prompt. The assistant then writes the code for you to add to your project. ## The skill file `skill.md` is an agent skill: Markdown with YAML front matter (`name`, `description`) and the steps to integrate floprouter. It covers keys, the base URL, request and response shapes, payer modes and the grant, the prepaid balance, routing, errors and what is safe to retry, streaming, timing, the MCP server and the CLI, and a verification step. The same file is served at three paths, for tools that look in different places: * `https://floprouter.com/skill.md` * `https://floprouter.com/skills/floprouter/SKILL.md` * `https://floprouter.com/.well-known/skills/floprouter/SKILL.md` ## For agents reading these docs * [`llms.txt`](https://docs.floprouter.com/llms.txt) indexes these docs, and [`llms-full.txt`](https://docs.floprouter.com/llms-full.txt) has every page in one file. * Every page is Markdown at its path plus `.md`. * [`https://floprouter.com/openapi.json`](https://floprouter.com/openapi.json) is the API schema. ## Also for agents * [MCP server](/mcp-server): floprouter as tools in any MCP client. * [CLI](/cli): the wallet steps (key, grant, deposit) on your machine. # Good to know Source: https://docs.floprouter.com/good-to-know How requests, prices and payments work on FLOP Network, and what the API does not offer. * **A provider is a miner.** In routing preferences, name a miner by its account address, or by the host of its session endpoint. * **Cost follows `max_tokens`.** A request escrows the prompt plus `max_tokens` at the model's price, with a minimum per request, and a settled session pays the whole escrow to the miner. Keep `max_tokens` close to what you need. * **The largest request is what one payment covers.** `context_length` is the largest prompt plus completion one request can pay for here. It is set by the escrow ceiling and is smaller than the model's own window. * **Sampling is fixed.** Each model's decode policy is set on chain and every reply is verified against it, so `temperature`, `top_p` and similar fields are accepted and reported as ignored. * **No tool calling.** No model on the network is served with tools yet. * **Amounts are in FLOP.** Prices, costs and your balance are FLOP. Devnet and testnet FLOP have no monetary value. * **A prepaid FLOP balance.** You fund it with an on-chain transfer and can [withdraw](/withdrawals) it. * **Accounts are wallets.** Keys come from a wallet signature. There are no organisations, workspaces or management keys. * **Every request is settled on chain.** Each response carries a `flop` record with its payment channel, and the settlement follows 2 to 4 minutes after the reply. See [payment channels and sessions](/sessions). * **You can be the payer of record.** In grant mode your wallet pays every session on chain. See [payer modes and grants](/payer-modes). * **Replies take 15 to 50 s.** A non-streaming call returns `202` with a session to poll when no reply is ready within about 85 s. * **No zero data retention.** Miners keep signed session evidence for audit and settlement, so `data_collection: "deny"` gets 503. ## Not offered Responses and legacy completions endpoints; embeddings, images, audio, video and rerank; plugins; presets, guardrails, batch and analytics. # Overview Source: https://docs.floprouter.com/index What floprouter is, what happens on each request, and where to start. Using a coding agent? Paste this prompt into Claude Code, Cursor, Codex or any LLM. It points the agent at the skill file, which has the exact steps, shapes and checks. floprouter is one API in front of every GPU miner and every model on FLOP Network. FLOP is a Substrate chain where miners sell LLM inference and are paid through payment channels. The router lists every registered miner, scores each one from its on-chain record, and sends your request to a ready miner, or to the miners you name. You write one request shape. Models on the network differ in prompt format and decode policy, and miners differ in how a channel is opened with them. The router handles those differences, so your code does not change when a model or a miner is added. It runs on FLOP devnet today. Devnet and testnet FLOP have no monetary value. ## What happens on each request 1. **A miner is chosen.** Auto mode takes the best ready miner for the model by score. You can name miners with the `provider` object instead. 2. **A payment channel opens on chain.** Escrow for this one request is locked, normally against the miner's signed offer. 3. **The miner answers.** The reply is checked against the miner's signed receipt before the request completes. On devnet a reply takes about 15 to 50 s. 4. **The miner settles.** The settlement is final on chain 2 to 4 minutes later, in the background. Follow it with `GET /v1/sessions/{id}` or in the [playground](https://floprouter.com/playground/). ## Base URL ```text theme={null} https://api.floprouter.com/v1 ``` Every path in these docs is relative to `https://api.floprouter.com`. Send your key as `Authorization: Bearer fr_...`. `https://api.floprouter.com/api/v1` serves the same routes as `https://api.floprouter.com/v1`. Not live yet ## Where to go next * [Send a first request](/quickstart) * [Pick models](/models) and [choose miners](/routing) * [Keep your wallet as the payer on chain](/payer-modes) * [Hand the work to a coding agent](/for-agents) * [Use an SDK you already have](/compatibility) * [See every endpoint](/api-reference/overview) ## What is live | Part | State | | - | - | | Miner directory, scores, models | Live | | Chat completions, auto and pinned routing | Live | | Session status with on-chain links | Live | | Wallet sign-in and API keys | Live | | Your wallet as the on-chain payer (grant) | Live | | Prepaid balance and withdrawals | Live | | Router fee charged | Live | | Streaming (text forwarded as the miner sends it) | Live | | Tool calls | Not supported | The website checks the endpoints against the API it talks to on every visit; the [status page](https://floprouter.com/status/) shows the result. ## For agents and LLMs * [`/skill.md`](https://floprouter.com/skill.md) is an agent skill with every step to integrate floprouter. The "Copy prompt for your agent" button points an agent at it. * [`/llms.txt`](https://floprouter.com/llms.txt) lists every page. [`/llms-full.txt`](https://floprouter.com/llms-full.txt) is the whole documentation in one file. * Every docs page is plain Markdown at its path plus `.md`, for example [`/docs/quickstart.md`](/quickstart.md). * The OpenAPI schema is at [`/openapi.json`](https://floprouter.com/openapi.json). # Limits and supported fields Source: https://docs.floprouter.com/limits Which request fields work, which are ignored or rejected, and the limits on each request. ## Request fields | Field | Support | | - | - | | `model` | Required. An id or model hash from `GET /v1/models`. | | `messages` | Required. Roles `system`, `developer`, `user`, `assistant`. Text content. | | `max_tokens` | 1 to 32768, default 256. `max_completion_tokens` is an alias. It sizes the escrow. | | `stream` | Text as the miner decodes it, see [streaming](/streaming). | | `provider` | Miner choice, see [routing](/routing). | | `flop` | `wait_for_settlement` (default `false`), `payer` (`grant` or `credit`) to override the key's payer mode, and `fallback_payer: "credit"` to fall back to balance mode when the grant cannot serve a request. | | `temperature`, `top_p`, `seed`, `stop`, penalties | Accepted and ignored. You cannot set sampling on FLOP Network today: each model has a decode policy fixed on chain, and the miner's reply is verified against it. The router reports such fields as ignored. | | `tools`, `tool_choice`, `functions` | Rejected: 400 today, 404 "No endpoints found that support tool use" on the extended API. Tool calls are not supported. Not live yet | | `models`, `route` | Model fallback list, see [fallbacks](/fallbacks). Not live yet | | `n` above 1 | Rejected with 400. | | `response_format`, `logprobs` | Ignored. | | other fields | Ignored, not rejected, so clients that send extra fields keep working. | ## Ignored parameters Not live yet Each model lists what it supports in `supported_parameters`; today that is `max_tokens`, because sampling is fixed by the model's decode policy on chain. Parameters a model ignores are named in the `X-Floprouter-Ignored-Parameters` response header and in `flop.ignored_parameters`. Send `provider.require_parameters: true` to have such a request refused instead. ## Per request * One payment channel per request. Multi-turn chat sends the history each time. * A non-streaming call answers within a response deadline (85 s on this server); past it you get `202` and poll the session. See [settlement](/settlement). * The escrow has a maximum per request. Past it the request fails with `escrow_limit`. * The router has a daily spending cap for the sessions it pays. Past it requests fail with `daily_cap_reached`. ## Per key * Rate limits apply per key. Past them the API answers 429. * In grant mode your grant's caps apply as well: total, per transaction, daily, and its expiry. The chain enforces them. ## Not supported * Tool and function calling. Not live yet * Images, audio, embeddings, the Responses API and the legacy completions API. # MCP server Source: https://docs.floprouter.com/mcp-server Add floprouter's tools to Claude Code, Claude Desktop, Cursor, VS Code, Windsurf, Codex CLI, Cline, Zed, Gemini CLI, Continue or any MCP client. `floprouter-mcp` gives an AI agent the floprouter API as tools: it can list models and miners, send paid chat requests to GPU miners on FLOP Network, and check generations, sessions, balance and grant state. It runs on your machine over stdio and is on npm, so every client starts it the same way: ```bash theme={null} npx -y floprouter-mcp ``` You need Node 18.17 or later and an API key (`fr_...`). Create the key with your wallet on the [account page](https://floprouter.com/account/), or run `npx floprouter login`. Without a key, the read-only tools still work. The commands below read the key from your shell. Run `export FLOPROUTER_API_KEY=fr_...` first, or put the key in place of `$FLOPROUTER_API_KEY`. ## Add it to your client Choose your client **Add it** for all your projects (`--scope user`). The key is saved in `~/.claude.json` on your machine. ```bash theme={null} claude mcp add floprouter --scope user -e FLOPROUTER_API_KEY="$FLOPROUTER_API_KEY" -- npx -y floprouter-mcp ``` Keep the server name before `-e`: the `-e` flag takes every `KEY=value` that follows it, and everything after `--` goes to the server. **For one repository**, shared through git, put this in `.mcp.json` at the project root. Claude Code fills `${FLOPROUTER_API_KEY}` from each person's environment, so no key is committed. It asks once before it loads a project server. ```json .mcp.json theme={null} { "mcpServers": { "floprouter": { "command": "npx", "args": ["-y", "floprouter-mcp"], "env": { "FLOPROUTER_API_KEY": "${FLOPROUTER_API_KEY}" } } } } ``` **Check it loaded:** `claude mcp list` shows `floprouter` as connected. In a session, `/mcp` lists its 9 tools. **Remove it:** ```bash theme={null} claude mcp remove floprouter --scope user ``` **Add it** to the config file. In the app, Settings, Developer, Edit Config opens it. | System | File | | - | - | | macOS | `~/Library/Application Support/Claude/claude_desktop_config.json` | | Windows | `%APPDATA%\Claude\claude_desktop_config.json` | | Linux | `~/.config/Claude/claude_desktop_config.json` | Add the `floprouter` entry inside `mcpServers`. Keep any servers already there. ```json claude_desktop_config.json theme={null} { "mcpServers": { "floprouter": { "command": "npx", "args": ["-y", "floprouter-mcp"], "env": { "FLOPROUTER_API_KEY": "fr_..." } } } } ``` Quit Claude Desktop completely and open it again. Closing the window is not enough. **Check it loaded:** the local MCP servers list in Settings shows `floprouter` as running, and its tools appear in a chat's tools menu. If it does not start, the log is `mcp-server-floprouter.log` in `~/Library/Logs/Claude/` (macOS) or `%APPDATA%\Claude\logs` (Windows). **Remove it:** delete the `floprouter` entry from the file and restart the app. **Add it** with one click. Run `npx floprouter login` first: the server reads the key from the file it writes, so the link carries no key. [![](/images/clients/cursor-light.svg) ![](/images/clients/cursor-dark.svg) Add to Cursor](cursor://anysphere.cursor-deeplink/mcp/install?name=floprouter\&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsImZsb3Byb3V0ZXItbWNwIl19) **Or by hand:** `~/.cursor/mcp.json` for all projects, or `.cursor/mcp.json` in one project. The path is the same on macOS, Windows and Linux (`~` is your home folder). ```json ~/.cursor/mcp.json theme={null} { "mcpServers": { "floprouter": { "type": "stdio", "command": "npx", "args": ["-y", "floprouter-mcp"], "env": { "FLOPROUTER_API_KEY": "fr_..." } } } } ``` Cursor also reads `"${env:FLOPROUTER_API_KEY}"` from its environment. An app started from the dock or Start menu often does not see variables from your shell profile, so the login file or a literal key is the reliable choice. **Check it loaded:** Cursor Settings, MCP (Customize, MCPs in recent versions) lists `floprouter` with its tools. The Output panel, MCP Logs, shows why a server did not start. **Remove it:** delete it in the same MCP settings, or remove the entry from `mcp.json`. **Add it** with one click. Run `npx floprouter login` first, so the link needs no key. VS Code shows the server's details before it installs anything. [Install in VS Code](https://vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%257B%2522name%2522%253A%2522floprouter%2522%252C%2522type%2522%253A%2522stdio%2522%252C%2522command%2522%253A%2522npx%2522%252C%2522args%2522%253A%255B%2522-y%2522%252C%2522floprouter-mcp%2522%255D%257D) **Or by hand,** for GitHub Copilot in VS Code: `~/.copilot/mcp-config.json` for all workspaces, or `.mcp.json` at a workspace root. The `${FLOPROUTER_API_KEY}` reference reads the key from the environment VS Code runs in, so the file holds no key. ```json ~/.copilot/mcp-config.json theme={null} { "mcpServers": { "floprouter": { "type": "stdio", "command": "npx", "args": ["-y", "floprouter-mcp"], "env": { "FLOPROUTER_API_KEY": "${FLOPROUTER_API_KEY}" } } } } ``` Older VS Code releases use `.vscode/mcp.json` with a `servers` object instead of `mcpServers`. VS Code marks that format as deprecated. **Check it loaded:** run `MCP: List Servers` from the Command Palette, pick `floprouter` and choose Show Output. In Copilot Chat agent mode, the tools picker lists its tools. **Remove it:** `MCP: List Servers`, `floprouter`, Uninstall. Or delete the entry from the file. Windsurf is now called Devin Desktop. The steps are the same for both names. **Add it** with the Devin CLI, for all projects (`-s user`): ```bash theme={null} devin mcp add -s user -e FLOPROUTER_API_KEY="$FLOPROUTER_API_KEY" floprouter -- npx -y floprouter-mcp ``` **Or by hand,** in the user config file: | System | File | | - | - | | macOS, Linux | `~/.config/devin/mcp_config.json` | | Windows | `%APPDATA%\devin\mcp_config.json` | | Windsurf before the rename | `~/.codeium/windsurf/mcp_config.json` | ```json mcp_config.json theme={null} { "mcpServers": { "floprouter": { "command": "npx", "args": ["-y", "floprouter-mcp"], "env": { "FLOPROUTER_API_KEY": "fr_..." } } } } ``` For one project, use `.devin/mcp_config.local.json`: it is kept out of git, so the key stays on your machine. **Check it loaded:** `devin mcp list`, or Customize, MCPs in the app. **Remove it:** ```bash theme={null} devin mcp remove -s user floprouter ``` **Add it:** ```bash theme={null} codex mcp add floprouter --env FLOPROUTER_API_KEY="$FLOPROUTER_API_KEY" -- npx -y floprouter-mcp ``` This writes to `~/.codex/config.toml` (Windows: `%USERPROFILE%\.codex\config.toml`). The CLI, the IDE extension and the desktop app share that file. **Then raise the startup timeout.** Codex waits 10 s for a server to start by default, and the first `npx` run downloads the package. Add `startup_timeout_sec` to the entry: ```toml ~/.codex/config.toml theme={null} [mcp_servers.floprouter] command = "npx" args = ["-y", "floprouter-mcp"] startup_timeout_sec = 60 [mcp_servers.floprouter.env] FLOPROUTER_API_KEY = "fr_..." ``` To keep the key out of the file, replace the `env` table with `env_vars = ["FLOPROUTER_API_KEY"]`. Codex then passes the variable from the shell you start it in. **Check it loaded:** `codex mcp list` shows `floprouter` as enabled. In a session, `/mcp` lists its tools. **Remove it:** ```bash theme={null} codex mcp remove floprouter ``` **Add it** in Cline: Customize, MCP, Edit Configuration (older versions: the MCP Servers icon, Configure MCP Servers). This opens `cline_mcp_settings.json`, which the VS Code extension and the Cline CLI share: | System | File | | - | - | | macOS, Linux | `~/.cline/data/settings/cline_mcp_settings.json` | | Windows | `%USERPROFILE%\.cline\data\settings\cline_mcp_settings.json` | ```json cline_mcp_settings.json theme={null} { "mcpServers": { "floprouter": { "command": "npx", "args": ["-y", "floprouter-mcp"], "env": { "FLOPROUTER_API_KEY": "fr_..." }, "disabled": false, "timeout": 120 } } } ``` `timeout` is in seconds. Cline's default is 60. **With the Cline CLI,** `cline mcp add floprouter -- npx -y floprouter-mcp` starts a short wizard. Enter `FLOPROUTER_API_KEY=fr_...` when it asks for environment variables. **Check it loaded:** the Installed list in Cline's MCP view shows `floprouter` with its tools. **Remove it:** the trash icon on the server's row, `cline mcp remove floprouter`, or delete the entry from the file. **Add it** in Zed: Settings, AI, MCP Servers, Add Server, Add Local Server. Or edit `settings.json` yourself: | System | File | | - | - | | macOS, Linux | `~/.config/zed/settings.json` | | Windows | `%APPDATA%\Zed\settings.json` | ```json settings.json theme={null} { "context_servers": { "floprouter": { "command": "npx", "args": ["-y", "floprouter-mcp"], "env": { "FLOPROUTER_API_KEY": "fr_..." } } } } ``` Zed calls MCP servers `context_servers`. It gives a tool call 60 s by default, which covers `chat`. **Check it loaded:** on the MCP Servers page, the dot next to `floprouter` turns green and its tooltip reads "Server is active". **Remove it:** the Uninstall (trash) button on its row, or delete the entry from `settings.json`. **Add it** for all projects (`-s user`): ```bash theme={null} gemini mcp add -s user -e FLOPROUTER_API_KEY="$FLOPROUTER_API_KEY" floprouter npx -- -y floprouter-mcp ``` Pass the key with `-e`. Gemini CLI removes environment variables whose names contain `KEY` before it starts a server, so a variable exported in your shell does not reach it otherwise. This writes to `~/.gemini/settings.json` (a project's own is `.gemini/settings.json`): ```json ~/.gemini/settings.json theme={null} { "mcpServers": { "floprouter": { "command": "npx", "args": ["-y", "floprouter-mcp"], "env": { "FLOPROUTER_API_KEY": "fr_..." } } } } ``` In the file, `"$FLOPROUTER_API_KEY"` is also accepted: Gemini CLI fills it from its environment. **Check it loaded:** `gemini mcp list` shows `floprouter` as connected. In a session, `/mcp` lists its tools. A server in an untrusted folder is not started; run `gemini trust` in that folder. **Remove it:** ```bash theme={null} gemini mcp remove -s user floprouter ``` Continue was acquired by Cursor. These steps are for the open-source extension, which stays available. **Add it** as a block file in your project, `.continue/mcpServers/floprouter.yaml` (or in `~/.continue/mcpServers/` for all projects): ```yaml .continue/mcpServers/floprouter.yaml theme={null} name: floprouter version: 0.0.1 schema: v1 mcpServers: - name: floprouter type: stdio command: npx args: - "-y" - "floprouter-mcp" env: FLOPROUTER_API_KEY: ${{ secrets.FLOPROUTER_API_KEY }} ``` The extension cannot read your shell's environment. Put the key in `~/.continue/.env` (or a `.env` at the workspace root) as `FLOPROUTER_API_KEY=fr_...`. Keep that file out of git. **Check it loaded:** MCP tools work in Agent mode. The tools menu in the chat input lists the `floprouter` tools. **Remove it:** delete the block file. Continue reloads its config by itself. Most MCP clients take the same JSON: an `mcpServers` object with a command, its arguments and its environment. Add this entry to your client's MCP config: ```json theme={null} { "mcpServers": { "floprouter": { "command": "npx", "args": ["-y", "floprouter-mcp"], "env": { "FLOPROUTER_API_KEY": "fr_..." } } } } ``` If the client asks for fields instead: transport `stdio`, command `npx`, arguments `-y floprouter-mcp`, environment variable `FLOPROUTER_API_KEY`. If it speaks streamable HTTP, see [Local HTTP transport](#local-http-transport) below. **Check it loaded:** the client should list 9 tools from `floprouter`, starting with `list_models`. Ask it to call `router_status`; that call is free. **Remove it:** delete the entry and restart the client. ## Tools | Tool | What it does | Moves FLOP | | - | - | - | | `list_models` | Models in the on-chain registry, with ready and reachable miners, the escrow per 1,000 tokens, the least charge per request and the largest request served. `only_available` filters. | no | | `list_miners` | Miners with score, rank, settle rate, sessions, strikes, calibration and reachability. Filters: `reachable`, `ready`, `model`, `min_score`, `sort`, `limit`, `offset`. | no | | `get_miner` | One miner in detail: history, stake, calibration, slashing, models, endpoints and recent channels. | no | | `chat` | One paid chat request. Takes `prompt` or `messages`, `model`, and optional `fallback_models`, `miner` (pin one or a list), `allow_fallbacks`, `max_tokens`, `payer`, `fallback_payer`, `wait_for_settlement`. Returns the reply, the `generation_id`, the cost in FLOP and the session. | spends FLOP | | `generation` | One request by its id: tokens, cost in FLOP (final once settled), finish reason, latency and the verified reply. | no | | `session_status` | Settlement state of a session: status, channel, miner, escrow, amount paid to the miner, explorer links. | no | | `account` | Your prepaid balance and deposit address, this key's usage and limits, and the state of your grant. | no | | `withdraw` | Sends prepaid FLOP back to the wallet that owns the key. That wallet is the one destination the API allows. | to your own wallet | | `router_status` | Network, sync state, miner and endpoint counts, and which payer modes the router offers. | no | The server describes these tools to the agent and tells it that each `chat` call spends FLOP, so it should not loop on it. Many clients also ask you before a tool runs. ## Your key The server reads the key from `FLOPROUTER_API_KEY`. If that is not set, it reads the file `npx floprouter login` writes (`~/.config/floprouter/config.json`), so one login serves the CLI and the MCP server. With neither, the read-only tools work and `account` says that no key is set. The server never sees a wallet key or seed. Creating an API key, signing a grant, depositing and withdrawing to the chain happen in your wallet on the [account page](https://floprouter.com/account/), or with the [CLI](/cli) on your machine. A key in a client's config file stays on your machine; do not commit it. ## Who pays Each key has a payer mode. In `grant` mode (the default) your wallet is the payer on chain, through a grant you sign once. In `credit` mode the router's wallet opens the channel and takes the cost from your prepaid balance. `chat` can override the mode per request with `payer`. See [payer modes and grants](/payer-modes). ## Timing A verified reply usually takes 15 to 50 s on devnet. `chat` waits up to 50 s, below the 60 s at which many clients stop a tool call. If the reply is not verified by then, `chat` returns `pending: true` with a `generation_id`; the request carries on, and `generation` returns it a minute later. Settlement on chain follows 2 to 4 minutes after the reply: check it with `session_status`. | Variable | Default | What it sets | | - | - | - | | `FLOPROUTER_TOOL_BUDGET_MS` | `50000` | How long `chat` waits before it returns the id | | `FLOPROUTER_TIMEOUT_MS` | `300000` | Per-request timeout of the other tools | | `FLOPROUTER_SETTLE_WAIT_MS` | `300000` | How long `chat` polls when `wait_for_settlement` is true | | `FLOPROUTER_BASE_URL` | `https://api.floprouter.com` | The router the server talks to | ## Local HTTP transport The package also serves streamable HTTP, for clients that connect to a URL instead of starting a process: ```bash theme={null} npx -y floprouter-mcp --http # http://127.0.0.1:8792/mcp npx -y floprouter-mcp --http --port 9000 --host 127.0.0.1 ``` Each request may carry its own key as `Authorization: Bearer fr_...`; otherwise the server uses its configured key. It listens on `127.0.0.1` by default. Bind it to another address only if everyone who can reach it may use that key. There is no hosted floprouter MCP server: the server runs on your machine. ## Troubleshooting > [accordion] The server does not start > > Run `node --version`: the server needs 18.17 or later. A client started from the dock or Start menu may find a different `node` than your terminal; put the full path to `npx` in `command` (for example `/usr/local/bin/npx`, or the output of `which npx`). Run `npx -y floprouter-mcp --version` in a terminal: it prints `0.1.0` when the package installs and runs. > [accordion] An old version keeps running > > `npx` caches packages. Run `npx -y floprouter-mcp@latest --version` once to fetch the newest release, or pin a version in `args`, for example `"floprouter-mcp@0.1.0"`. > [accordion] The key is not set > > `account` returns `no API key configured` and `chat` fails with 401. Check the `env` block in your client's config, or run `npx floprouter login`. Restart the client after a change. In Gemini CLI, pass the key with `-e`; in Continue, put it in a `.env` file. > [accordion] 401 unauthorized > > The key is missing, mistyped or revoked. Create a new one on the [account page](https://floprouter.com/account/) or with `npx floprouter login`, and replace it in the config. > [accordion] 402 insufficient balance or grant > > `insufficient_balance`: your prepaid balance does not cover the escrow and fee. Deposit FLOP (`npx floprouter deposit 1`) or lower `max_tokens`. `grant_required`, `grant_expired` and similar: in grant mode your grant cannot pay. Sign one with `npx floprouter grant` or on the account page, or pass `payer: "credit"`. `insufficient_funds`: your wallet cannot cover the escrow. > [accordion] 503 no miner ready > > `no_miner_available`: no ready miner serves that model right now. Call `list_models` with `only_available: true` and pick one, or give `fallback_models`. `all_attempts_failed`: every miner tried failed before any output; wait for the retry time in the message and try again. If an attempt locked escrow, it comes back to the payer when that channel closes; `session_status` shows it. > [accordion] chat returns pending > > The reply took longer than 50 s. Call `generation` with the `generation_id` a minute later. Raising `FLOPROUTER_TOOL_BUDGET_MS` helps only if your client allows tool calls longer than 60 s. # For miner operators Source: https://docs.floprouter.com/miner-operators Make your miner reachable, see how it is scored, and what the router checks. Your miner is in the [directory](https://floprouter.com/miners/) as soon as it is registered on chain. To receive routed sessions, the router also needs your worker's URL. Session URLs are not on chain, so you submit it. ## Submit your endpoint Use the [form](https://floprouter.com/operators/) or: ```bash theme={null} curl -X POST https://api.floprouter.com/v1/miners//endpoint \ -H "Content-Type: application/json" \ -d '{"url": "https://miner.example.org"}' ``` `200` accepted and routable, `202` recorded but not routable until the chain ties the session key to your miner, `422` rejected or unreachable. No key is needed. Anyone may submit a URL; the proof decides which miner it belongs to. ## What the router checks 1. The URL is https, canonical, and resolves to public addresses. 2. `GET /session/info` answers 401 with a session challenge, as a live worker does. 3. `POST /session/info-proof` answers a fresh random challenge with a signature for this chain. 4. The account named in the proof is a registered miner. 5. The session key that signed is tied to that miner on chain: by a signed offer of yours, or a finalized channel of yours that used it. An entry that passes 1 to 4 but not 5 is kept as "key not tied" and is not routed to. Publish a signed offer, or complete one channel, and the next check picks it up. Entries are checked again every few minutes and before every session, and dropped when they keep failing. Use a host name that is yours and not similar to floprouter, so nobody mistakes your worker for this service. ## How you are scored Your score comes from your on-chain record: how your paid sessions ended, how many and how recent, how many payers, your stake, your slashing record and your calibration. The formula is not published; every input is shown on your [miner page](https://floprouter.com/miners/). Router-measured facts (endpoint answers, proof latency) are shown separately and are not part of the score. See [miners and scores](/miners). ## Getting more sessions * Keep your calibration live and your worker reporting ready. * Publish signed session offers. Grant-mode requests use offers, and an offer ties your session key to your account. * Settle every channel. Timeouts and failed acknowledgements lower the score. # Miners and scores Source: https://docs.floprouter.com/miners How the directory is built, what the score is made from, and how a miner operator submits an endpoint. ## Where the list comes from Every miner in the on-chain registry is listed, reachable or not. Stake, calibration, capacity, slashing and models come from chain storage, read at a finalized block and refreshed every few minutes. Session history comes from finalized chain events: every compute channel the miner was paid through and how it ended. New miners appear on the next pass with no manual step. ## The score A number from 0 to 100, with a rank. It is computed from on-chain facts: * how the miner's paid sessions ended: settled, timed out, acknowledgement expired, refunded, voided, fraud upheld, * how many there were, how recent, and from how many distinct payers, * stake, * slashing record: strikes, blacklist, failed acknowledgements, * the state of its hardware calibration. The exact formula is not published. Every input is returned beside the score, so anyone can judge a miner for themselves. The same chain state always gives the same score. Scores are recomputed about once a minute. Facts the router measures itself, such as whether the endpoint answers and how fast, are reported separately under `router_measured` and are not part of the score. ## Endpoints Session URLs are not on chain. The router collects candidate URLs from public sources and from operators, and accepts one once the worker behind it proves which miner it is: 1. The URL is https, canonical, and resolves to public addresses and no private ones. 2. `GET /session/info` answers 401 with a session challenge, as a live worker does. 3. `POST /session/info-proof` answers a fresh random challenge with a signature for this chain. 4. The account named in the proof is a registered miner. 5. The session key that signed is tied to that miner on chain, by a signed offer of the miner or a finalized channel of the miner that used it. An entry that passes 1 to 4 but not 5 is kept as not yet tied and is never routed to. Entries are checked again every few minutes and before every session. | Directory label | Meaning | | - | - | | Ready | Proven, and the worker reports ready. Takes traffic. | | Reachable, not ready | Proven and answering, but the worker reports it is not ready. | | Key not tied | Valid proof, but the session key is not yet tied to the miner on chain. | | Down | Proven before, failing its checks now. | | No endpoint | No session URL is known. | ## Submitting an endpoint Miner operators submit their worker URL so the router can reach them. See [for miner operators](/miner-operators). ## Network totals `GET /v1/stats` returns totals for the whole network: miners, reachable miners, models, sessions routed, settle rate. Live # Models Source: https://docs.floprouter.com/models Which models the network serves, how to name them, and how one request shape covers all of them. ## List the models ```bash theme={null} curl https://api.floprouter.com/v1/models ``` No key is needed. Every verified model in the chain registry is listed, with how many miners serve it now: ```json theme={null} { "id": "qwen/qwen3-8b", "object": "model", "name": "Qwen/Qwen3-8B", "hash": "0xfab8ec57f3bc1b5d4ca644fe12fab2ca1c35c24697d577c610b382cfea14d52d", "params_billion": 8, "precisions": ["BF16"], "gflops_per_token": 17, "miners_reachable": 3, "miners_ready": 1, "available": true, "pricing": { "escrow_per_1000_tokens": "0.05", "basis": "token_price", "tariff_floor_per_1000_tokens": "0.000000000000017001", "router_fee_percent": 5 } } ``` | Field | Meaning | | - | - | | `id` | What you send as `model`. The model hash works too. | | `miners_reachable` | Miners serving this model whose session endpoint the router has proven. | | `miners_ready` | Of those, how many report ready. A request needs at least one. | | `available` | `true` when `miners_ready` is 1 or more. | | `pricing.escrow_per_1000_tokens` | What the router escrows per 1,000 tokens of prompt plus `max_tokens`. | | `pricing.tariff_floor_per_1000_tokens` | The chain's minimum for the same tokens. | | `pricing.router_fee_percent` | The router fee as a percentage of escrow. | The [models page](https://floprouter.com/models/) shows the same data live, and each model has a page with the miners serving it. ### The extended model object Not live yet The model object gains `context_length`, `architecture`, per-token `pricing`, `top_provider` and `supported_parameters`. The FLOP details move under `flop`; the top-level `available`, `miners_ready`, `miners_reachable` and `params_billion` stay for one release. ```json theme={null} { "id": "qwen/qwen3-8b", "name": "Qwen/Qwen3-8B", "context_length": 10000, "architecture": {"modality": "text->text", "input_modalities": ["text"], "output_modalities": ["text"]}, "pricing": {"prompt": "", "completion": "", "request": "0"}, "top_provider": {"context_length": 10000, "max_completion_tokens": "", "is_moderated": false}, "supported_parameters": ["max_tokens"], "flop": { "model_hash": "0x...", "providers_reachable": 3, "providers_ready": 1, "available": true, "min_charge_per_request": "0.01", "escrow_per_1000_tokens": "0.05", "router_fee_percent": 5, "pricing_note": "A request escrows prompt plus max_tokens at this price ..." } } ``` * `pricing` is in FLOP per token, not USD. * `context_length` is the largest prompt plus completion one payment covers on this router, not the model's own window. With a 0.5 FLOP escrow ceiling at 50 FLOP per million tokens, that is 10,000 tokens, although today's models have a 32,768-token window. * The cost follows `max_tokens`, not the tokens produced: a request escrows prompt plus `max_tokens`, and a settled session pays the whole escrow. One model, and the miners serving it, one endpoint per miner: ```bash theme={null} curl https://api.floprouter.com/v1/models/qwen/qwen3-8b curl https://api.floprouter.com/v1/models/qwen/qwen3-8b/endpoints curl https://api.floprouter.com/v1/models/count ``` Each endpoint is one miner: `tag` is the miner's address, `provider_name` its endpoint host, `status` 0 for ready, -1 for reachable but not ready, -2 for not answering. `uptime_last_1d` is the share of signed-proof probes that succeeded, and `latency_last_30m.p50` the mean time to the verified reply in seconds. The miner's score, key binding and live signed offer are under `flop`. ## One request shape for every model Each model on FLOP Network has a decode policy fixed on chain, and miners run different worker versions. The router reads the model's policy, builds the turn in the format that model and worker expect, and verifies the reply against the miner's signed receipt. You send `model`, `messages` and `max_tokens` the same way for every model. A model added to the registry is usable with no change on your side. Sampling parameters (`temperature`, `top_p`, `seed`) are accepted and ignored, because the decode policy on chain decides them. Every miner serving a model answers with the same policy. ## Which miners serve a model ```bash theme={null} curl "https://api.floprouter.com/v1/miners?model=qwen/qwen3-8b&reachable=true&view=full" ``` See [miners and scores](/miners) for the fields, and [provider selection](/routing) to send a request to particular miners. # Payer modes and grants Source: https://docs.floprouter.com/payer-modes Who pays on chain for each session, and why the grant keeps the on-chain record with your wallet. Every session opens a payment channel on chain. The account that opens it is the channel's payer, recorded in the channel's `agent` field. floprouter has two ways to pay: `grant` and `credit`. You choose per key (new keys start in `grant`), and can override per request with `"flop": {"payer": "credit"}`. Switch a key's mode on the [account page](https://floprouter.com/account/) or with `PATCH /v1/auth/keys/{id}` and `{"payer": "grant"}` or `{"payer": "credit"}`. | | Grant | Balance | | - | - | - | | Payer on chain | your wallet | the router's wallet | | What you sign | one grant, once | nothing per request | | Escrow paid from | your wallet | your router balance | | Router fee paid from | your router balance | your router balance | | Best for | people and agents that want the on-chain record in their own name | quick scripts and agents | Every response says who paid, in `flop.payer`: ```json theme={null} "payer": {"address": "5...", "kind": "session-key"} ``` `kind` is `session-key` when your wallet paid through a grant, and `router-wallet` when the router's wallet paid. ## Grant mode (`grant`, recommended) Live You sign one extrinsic with your wallet: `flopSessionKeys.createSession`. It names a delegate key held by the router and sets limits: a total spending cap, a per-transaction limit, a daily cap, a duration in blocks, and the pallets the delegate may use. floprouter asks for `ComputeChannel` and no other pallet. After that, for each request, the router signs `flopSessionKeys.executeViaSession` with its delegate key. The chain runs the inner call, opening the channel, **as your account**. So: * The channel's payer on chain is your address, not the router's. The explorer shows your address as the payer. * The escrow comes from your wallet. * Your wallet signs nothing during the session. The router holds the per-channel session key and does everything after the open. Grant mode opens every channel against a miner's signed offer. When no ready miner has a live offer, or the grant cannot pay, a grant-mode request fails. To have it run in balance mode instead, send `"flop": {"fallback_payer": "credit"}`. It is off by default, so your wallet stays the payer unless you ask otherwise. ### What the delegate can and cannot do * It can open compute channels to any miner, at any escrow, within your caps. The chain enforces the caps. * It cannot transfer your funds or call anything outside `ComputeChannel`. * It stops working when the grant expires or when you revoke it with `flopSessionKeys.revokeSession`, signed by your wallet. ### Limits The chain limits how long a grant lasts and how many grants one delegate key can hold. `GET /v1/grants/params` returns the delegate address, the caps the router asks for (`amounts`), the chain's limits (`limits`), and the exact call to sign, both as `call` (pallet, method, arguments) and as encoded `call_data`. Without a key, pass `?address=`. `GET /v1/grants` returns your grant's state: sessions left and expiry. After you sign, `POST /v1/grants/sync` asks the router to read it from the chain at once. ```bash theme={null} curl https://api.floprouter.com/v1/grants/params -H "Authorization: Bearer $FLOPROUTER_API_KEY" curl https://api.floprouter.com/v1/grants -H "Authorization: Bearer $FLOPROUTER_API_KEY" curl -X POST https://api.floprouter.com/v1/grants/sync -H "Authorization: Bearer $FLOPROUTER_API_KEY" ``` The [account page](https://floprouter.com/account/) does all three and builds the transaction for your wallet to sign. Signing the same delegate again replaces the old grant, so renewing is the same one signature. ## Balance mode (`credit`) Live The router's wallet opens the channel and the cost, escrow plus fee, is taken from your prepaid balance. Nothing to sign per request. On chain, the payer of each session is the router, not you. ## What the current server offers `GET /health` lists the payer modes the server offers in `payer.modes`, and the router wallet's address in `payer.router_wallet`. Every response says who actually paid, in `flop.payer`. # Quickstart Source: https://docs.floprouter.com/quickstart Send a first request in three steps with plain HTTP. Using a coding agent? Paste this prompt into Claude Code, Cursor, Codex or any LLM. It points the agent at the skill file, which has the exact steps, shapes and checks. ## 1. Get a key Open the [account page](https://floprouter.com/account/), connect a Polkadot wallet (polkadot-js, Talisman or SubWallet), and sign the login message. Signing it is free and moves no funds. You get a key that starts with `fr_`. It is shown once. ```bash theme={null} export FLOPROUTER_API_KEY=fr_... ``` A new key makes your wallet the payer on chain, which needs one more signature: the grant, on the same page. To skip the grant, switch the key to **Balance** there and deposit a little FLOP. See [payer modes](/payer-modes). ## 2. Pick a model ```bash theme={null} curl https://api.floprouter.com/v1/models ``` A model with `available: true` has at least one ready miner. The [models page](https://floprouter.com/models/) shows the same list. No key is needed for this call. ## 3. Send a request ```bash curl theme={null} curl https://api.floprouter.com/v1/chat/completions \ -H "Authorization: Bearer $FLOPROUTER_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "qwen/qwen3-8b", "messages": [{"role": "user", "content": "What is a payment channel?"}], "max_tokens": 128 }' ``` ```js fetch theme={null} const res = await fetch("https://api.floprouter.com/v1/chat/completions", { method: "POST", headers: { Authorization: `Bearer ${process.env.FLOPROUTER_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ model: "qwen/qwen3-8b", messages: [{ role: "user", content: "What is a payment channel?" }], max_tokens: 128, }), }); const reply = await res.json(); console.log(reply.choices[0].message.content); ``` ```python Python theme={null} import os, requests res = requests.post( "https://api.floprouter.com/v1/chat/completions", headers={"Authorization": f"Bearer {os.environ['FLOPROUTER_API_KEY']}"}, json={ "model": "qwen/qwen3-8b", "messages": [{"role": "user", "content": "What is a payment channel?"}], "max_tokens": 128, }, timeout=120, ) print(res.json()["choices"][0]["message"]["content"]) ``` To use an SDK or framework instead, see [SDK compatibility](/compatibility). The call returns when the miner's reply is verified, usually in 15 to 50 s. Set client timeouts to 120 s or more. `max_tokens` sizes the escrow, so keep it close to what you need. ## 4. Read the response The body is a chat completion with two extra fields: `provider`, the miner that served it, and `flop`, the record of the session. ```json theme={null} { "id": "gen-mwto3ds1-0811fd3833f3", "object": "chat.completion", "model": "qwen/qwen2.5-0.5b-instruct", "provider": "5HdTbhVY9jZCsfJVFENYF89hRfkBvoby2YxPest3XLLRhnrt", "choices": [{"index": 0, "message": {"role": "assistant", "content": "..."}, "finish_reason": "length"}], "usage": {"prompt_tokens": 6, "completion_tokens": 24, "total_tokens": 30}, "flop": { "session_id": "gen-mwto3ds1-0811fd3833f3", "status": "settling", "channel_id": "0x96cc8fd277657749a32b2acd6b0ee035fe5837785663a8d31ce4179212f3cddb", "miner": "5HdTbhVY9jZCsfJVFENYF89hRfkBvoby2YxPest3XLLRhnrt", "via": "force", "payer": {"address": "5Gmdxzsm...", "kind": "router-wallet"}, "escrow": "0.01", "miner_paid": null, "router_fee": {"percent": 5, "amount": "0.0005", "charged": false, "status": "pending"}, "on_chain": {"open_block": 4467284, "outcome": null, "outcome_block": null, "outcome_tx": null} } } ``` This is an abridged real response from devnet. Amounts are decimal strings in FLOP. ## 5. Watch it settle ```bash theme={null} curl https://api.floprouter.com/v1/sessions/gen-mwto3ds1-0811fd3833f3 ``` `status` moves from `settling` to `settled`, and `miner_paid` and `on_chain.outcome_tx` fill in, 2 to 4 minutes after the reply. The channel is on the explorer at `https://explorer.devnet.flop.network/channels/`. ## Next * [Provider selection](/routing): choose miners yourself. * [Payer modes](/payer-modes): keep your wallet as the payer on chain. * [Streaming](/streaming): read the reply as it arrives. * [For agents](/for-agents): hand this to a coding agent. # Provider selection Source: https://docs.floprouter.com/routing Choose miners with the provider object, or let auto mode choose by score. Routing preferences go in the `provider` object. A provider is a miner, named by its account address. ## Auto mode Send no `provider` object and the router chooses. It considers miners that * serve the requested model, * have a session endpoint the router has proven, and * report ready, and tries them in order of score. In grant mode a miner also needs a live signed offer. What happens when a miner fails is on the [fallbacks](/fallbacks) page. The score runs from 0 to 100 and comes from on-chain facts: how a miner's paid sessions ended, how many and how recent, who paid for them, its stake, its slashing record and its calibration. The formula is not published. The inputs are, on every miner in `GET /v1/miners` and on the [miners page](https://floprouter.com/miners/). ## The provider object | Field | Type | Meaning | | - | - | - | | `order` | string\[] | Try these miners first, in this order. | | `only` | string\[] | Use these miners and no others. | | `ignore` | string\[] | Never use these miners. | | `sort` | `reliability` or `latency` | `reliability` (default) orders by score. `latency` orders by the router's measured proof latency. | | `allow_fallbacks` | boolean | With `order`: whether other miners may be tried after the listed ones. Default `true`. | ### More routing preferences Not live yet More routing preferences: | Field | Here | | - | - | | `order`, `only`, `ignore` | Miner addresses, or the host of a miner's session endpoint. | | `sort` | A string or `{by, partition}`. `reliability` (the default): the miner's score. `latency` and `throughput`: router-measured time to the verified reply. `price`: every miner serving a model costs the same here, so the default order applies. | | `max_price` | `{prompt, completion, request}` in FLOP, per million tokens (`request`: per request). A model above it is skipped. | | `require_parameters` | `true`: refuse the request (503) when the model ignores a parameter you sent, instead of ignoring it. | | `quantizations` | Matched against the model's precision in the chain registry, `bf16` today. | | `data_collection: "deny"`, `zdr: true` | Cannot be honoured, because miners keep signed session evidence for audit and settlement. The request gets 503. | | `preferred_min_throughput`, `preferred_max_latency` | Accepted and ignored. | `GET /v1/providers` lists the miners with a proven endpoint, one entry per miner (`slug` is the miner address). The directory with every registered miner stays at `GET /v1/miners`. Pin one miner, and fail instead of moving to another: ```json theme={null} { "model": "qwen/qwen3-8b", "messages": [{"role": "user", "content": "Hello"}], "provider": {"only": ["5HKiGNFSqSyEMVMjjr8JBKkkppytaqFZCRm27KGbCeHhUq92"], "allow_fallbacks": false} } ``` Prefer two miners, then let the router choose: ```json theme={null} "provider": {"order": ["5HKiGN...", "5CJxjZ..."], "allow_fallbacks": true} ``` Avoid a miner: ```json theme={null} "provider": {"ignore": ["5HbvZY..."]} ``` Order by measured latency: ```json theme={null} "provider": {"sort": "latency"} ``` ## Which miner served you * `provider` at the top level of the response is the miner's address. * `flop.miner`, `flop.endpoint` and `flop.via` say who served it and how the channel was opened: `offer` (against the miner's signed offer) or `force` (a force-open, when the miner has no live offer). * `flop.attempts` lists every try, failed ones included, with the stage it reached and the error. ## Finding miners ```bash theme={null} # miners with a proven endpoint for one model, best first curl "https://api.floprouter.com/v1/miners?reachable=true&view=full&model=qwen/qwen3-8b" # every registered miner, by settle rate curl "https://api.floprouter.com/v1/miners?sort=settle_rate&limit=1000" ``` Filters: `reachable`, `ready`, `active`, `calibrated`, `model`, `min_score`. Sort: `score`, `settle_rate`, `sessions`, `stake`, `latency`, `capacity`, with `order`, `limit` and `offset`. Without `view=full`, `reachable=true` returns the compact list of proven pairs. ## Price FLOP Network has no per-miner price, so the router does not route on price. It routes on reliability and reachability. See [fees](/fees). # Payment channels and sessions Source: https://docs.floprouter.com/sessions What a session is, how its payment channel moves on chain, and how to read both. Each request is one **session**. A session opens one **payment channel** on FLOP Network: an on-chain account between the payer and the miner that holds the escrow for this request. The miner answers through it and is paid from it. ## The life of a channel | Stage | On chain | In the session record | | - | - | - | | Opened | The channel exists with the escrow locked. Opened against the miner's signed offer (`via: "offer"`) or by force-open (`via: "force"`). | `status: "running"`, `channel_id`, `on_chain.open_block` | | Answered | Nothing yet. The reply and the miner's signed receipt travel off chain. | `status: "settling"`, `usage` | | Settled | The miner posts the settlement and the escrow is paid out. | `status: "settled"`, `miner_paid`, `on_chain.outcome_tx` | | Recovered | If the miner goes silent, the router closes the channel with a timeout or force-settle. | `status: "recovering"`, then the outcome | Settlement timing and the recovery calls are on the [settlement](/settlement) page. ## Read a session ```bash theme={null} curl https://api.floprouter.com/v1/sessions/ -H "Authorization: Bearer $FLOPROUTER_API_KEY" ``` The session id is the `id` of the chat completion, and `flop.session_id`. The record carries: | Field | Meaning | | - | - | | `status` | `running`, `settling`, `settled`, `refunded`, `recovering`, `failed`, `fraud` or `voided`. | | `channel_id` | The payment channel, `0x` plus 64 hex characters. | | `miner`, `endpoint`, `via` | Who served it and how the channel was opened. | | `payer` | `address` and `kind`: who paid on chain (see [payer modes](/payer-modes)). | | `escrow`, `miner_paid` | What was locked, and what the settlement paid. | | `router_fee` | Percent, amount and `status`: `pending`, `charged`, `not_charged` or `not_billed`. | | `on_chain` | `open_block`, `outcome`, `outcome_block`, `outcome_tx`. | | `attempts` | Every try, with the miner, stage, error and any recovery calls. | | `reply` | The verified reply, to the key that made the request, once there is one. | ## Generation records Not live yet A generation lookup reads the same session by its id: ```bash theme={null} curl "https://api.floprouter.com/v1/generation?id=gen-..." -H "Authorization: Bearer $FLOPROUTER_API_KEY" ``` It returns tokens, `total_cost` in FLOP, finish reason, latency and the verified reply, with the full session under `flop`. Every chat response carries the id in the `X-Generation-Id` header as well as in `id`. ### Cost in the response `usage.cost` is the request's cost in FLOP: escrow plus router fee. It is final when the session settles (`usage.cost_details.final`), and 0 for a session that is refunded. `usage.cost_details.upstream_inference_cost` is the escrow, split into prompt and completion by token share. ## List your sessions ```bash theme={null} curl "https://api.floprouter.com/v1/sessions?limit=20" -H "Authorization: Bearer $FLOPROUTER_API_KEY" ``` ## On the explorer * A channel: `https://explorer.devnet.flop.network/channels/` * A transaction: `https://explorer.devnet.flop.network/transactions/` * A payer or miner: `https://explorer.devnet.flop.network/account/
` In grant mode the explorer shows your address as the payer of the channel. # Settlement Source: https://docs.floprouter.com/settlement Timing, session states, and how to follow a payment channel to its final state on chain. Each request opens one payment channel. Its life on devnet: | Step | Typical time | | - | - | | Miner chosen, channel opened | a few seconds | | Verified reply | about 15 to 50 s after the request, sometimes longer | | Settlement final on chain | 2 to 4 minutes after the reply, in the background | ## When the call returns A non-streaming call returns as soon as the reply is verified, with `flop.status: "settling"`. The settlement continues in the background. To wait for the settlement instead, send `"flop": {"wait_for_settlement": true}`. The call then returns once the settlement is final, with `miner_paid` set, but no later to the response deadline below. ### The response deadline Some proxies drop responses that stay idle for long. So a non-streaming call answers within a fixed deadline (85 s on this server). If no verified reply has arrived by then, it returns `202` instead of failing: ```json theme={null} { "id": "gen-...", "object": "chat.completion.pending", "status": "pending", "message": "no verified reply within 85 s; the session continues. Poll GET /v1/sessions/gen-... until reply is set, or use stream: true.", "poll": "/v1/sessions/gen-...", "flop": {"session_id": "gen-...", "status": "running"} } ``` The session keeps running. Poll `GET /v1/sessions/{id}` with the same key until `reply` is set. Streaming avoids this case entirely. ## Following a session ```bash theme={null} curl https://api.floprouter.com/v1/sessions/ ``` | `status` | Meaning | | - | - | | `running` | The request is in progress. | | `settling` | The reply was delivered. The settlement is not final yet. | | `settled` | The miner was paid on chain. `miner_paid` and `on_chain.outcome_tx` are set. | | `refunded` | The escrow went back to the payer. | | `recovering` | The miner went silent after the channel opened. The router is closing the channel on chain. | | `failed` | No attempt produced output. | | `fraud`, `voided` | Final outcomes decided on chain. | `on_chain` holds the open block, the outcome, the outcome block and the transaction. With the key that made the request, the record also carries `reply`: the verified reply, once there is one. Look the channel up on the explorer: `https://explorer.devnet.flop.network/channels/`. ## When a miner goes silent The router watches every channel it opened. If a channel stays open past its deadlines, the router sends the matching recovery call on chain (`expire_force_open`, `timeout`, `force_settle` or `finalize`). These calls are open to anyone on FLOP; the router pays their transaction fees. The session's `attempts[].recovery` lists what was sent. ## One channel per request A multi-turn conversation is one request per turn, each with its own channel. Send the whole history in `messages` each time, as with any chat API. # Streaming Source: https://docs.floprouter.com/streaming Text as the miner decodes it, how it is verified, and what the stream carries. `"stream": true` returns server-sent events of `chat.completion.chunk` objects, ending with `data: [DONE]`. Live The stream carries: 1. the first bytes once the router's own checks pass (payer, balance, grant, miner availability), or after 8 s, 2. keep-alive comments (lines that start with `:`, such as `: FLOPROUTER PROCESSING`) at least every 15 s while the miner works, so proxies and clients do not time out, 3. text deltas, forwarded **as the miner streams them**, 4. a last chunk with `usage` and the `flop` session record (it repeats `finish_reason` in `choices`), 5. `data: [DONE]`. ```python Python theme={null} import json, os, requests with requests.post( "https://api.floprouter.com/v1/chat/completions", headers={"Authorization": f"Bearer {os.environ['FLOPROUTER_API_KEY']}"}, json={"model": "qwen/qwen3-8b", "messages": [{"role": "user", "content": "Hello"}], "stream": True}, stream=True, timeout=300, ) as res: for line in res.iter_lines(decode_unicode=True): if not line or not line.startswith("data: "): continue # blank lines and ': keep-alive' comments data = line[6:] if data == "[DONE]": break chunk = json.loads(data) if "error" in chunk: raise RuntimeError(chunk["error"]) for choice in chunk.get("choices", []): print(choice["delta"].get("content", ""), end="", flush=True) ``` ```bash curl theme={null} curl -N https://api.floprouter.com/v1/chat/completions \ -H "Authorization: Bearer $FLOPROUTER_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "qwen/qwen3-8b", "messages": [{"role": "user", "content": "Hello"}], "stream": true}' ``` The router forwards text as soon as the miner sends it. Miners on devnet today (worker 0.1.418) send the reply in one piece at the end of the turn, so for now a stream shows keep-alives and then the whole reply at once. When workers stream as they decode, the same requests show text as it is produced; nothing changes on your side. ## Verification The streamed text is provisional while it arrives. When the turn ends, the miner's signed receipt is checked against the whole reply, and the finish chunk follows that check. The receipt commits to the same bytes, so the two match. If they ever did not, the stream ends with an error chunk that carries the verified text: ```json theme={null} {"error": {"message": "the streamed text differs from the verified reply; use the verified content", "type": "server_error", "code": "stream_mismatch", "verified_content": "..."}} ``` Once text has reached you, the router does not fail over to another miner, so you never get two answers for one request. ### Errors after the stream started Not live yet A mid-stream error arrives as one chunk with a top-level `error` (`code`, `message`, `metadata`) and `choices: [{"delta": {"content": ""}, "finish_reason": "error"}]`. The stream ends after it, with no `[DONE]`. The reason is in `error.metadata.reason`, and for `stream_mismatch` the verified text is in `error.metadata.verified_content`. ## Why stream * You see text within seconds instead of waiting for the whole reply. * Non-streaming calls have a response deadline. When no verified reply arrives in time, they return `202` with a pending body and you poll for the reply (see [settlement](/settlement)). A stream has no such deadline. Streams never wait for the settlement. Read it from `GET /v1/sessions/{id}` with the `flop.session_id` from the last chunk. # Withdrawals Source: https://docs.floprouter.com/withdrawals Send your prepaid balance back to your wallet. `POST /v1/balance/withdraw` sends FLOP from the deposit wallet to the wallet that owns your key. It cannot send anywhere else. ```bash theme={null} curl -X POST https://api.floprouter.com/v1/balance/withdraw \ -H "Authorization: Bearer $FLOPROUTER_API_KEY" \ -H "Content-Type: application/json" \ -d '{"amount": "0.5"}' ``` | Field | Meaning | | - | - | | `amount` | Decimal FLOP, or `"all"` for the whole available balance. | | `to` | Optional. When given, it must equal the wallet that owns the key. | The amount is held first, so a withdrawal cannot race a session or another withdrawal. The chain fee is estimated and taken out of the amount sent. ## Response `200` once the transfer is final on chain. The shape, with placeholder values: ```json theme={null} { "object": "withdrawal", "id": "...", "to": "5...", "status": "sent", "requested": "0.5", "sent": "", "chain_fee": "", "tx": "0x...", "block": 4498929, "balance_after": "" } ``` `sent` is the requested amount minus the fee estimate. `chain_fee` is the fee the chain charged. The ledger in `GET /v1/balance` books both, as `withdrawal` and `withdrawal_fee`. ## Limits and errors * One withdrawal per wallet at a time, and at most 10 per wallet per hour. | HTTP | `code` | What it means | | - | - | - | | 400 | `invalid_amount`, `amount_too_small`, `invalid_destination` | The amount or `to` is not valid. Nothing was sent. | | 402 | `insufficient_balance` | The available balance is less than the amount. Nothing was sent. | | 409 | `withdrawal_in_progress` | Another withdrawal for this wallet is in flight. Wait for it. | | 429 | `rate_limited` | More than 10 in the hour. Wait for `Retry-After`. | | 503 | `withdrawals_unavailable`, `treasury_insufficient`, `withdrawal_failed` | The transfer was not sent. Your balance is unchanged. Retry later. | | 503 | `withdrawal_outcome_unknown` | The transfer's outcome is not known yet. The amount stays held until the router reconciles it. Do not retry; check `GET /v1/balance`. |