Connect
Connect
OpenAI SDKs, curl, agent frameworks, editor tools, the MCP server and the CLI.
floprouter speaks the OpenAI chat completions API. Anything that lets you set an OpenAI-compatible base URL can use it. You need two values:
| Setting | Value |
|---|---|
| Base URL | https://api.floprouter.com/v1 |
| API key | your fr_... key from the account page |
| Model | an id from /v1/models, for example qwen/qwen3-8b |
Two things to know before you connect a tool:
- Plain chat only. Tool calling is not supported, so a request that sends
toolsis rejected with 400. Agent modes in editors and frameworks usually send tools. Use their chat mode. - Replies are slow by API standards. 15 to 50 s on devnet. Raise client timeouts to at least 120 s.
OpenAI Python SDK
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={"flop": {"wait_for_settlement": False}}, )
Router fields (provider, flop) go in extra_body. The flop object of the response is in reply.model_extra["flop"].
OpenAI JavaScript SDK
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" }], flop: { wait_for_settlement: false }, });
curl
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": "Hello"}], "flop": {"wait_for_settlement": false}}'
Agent frameworks
Plain chat works; tool calls do not. The LangChain and Vercel AI SDK snippets below were checked against responses recorded from the live API, not with separate paid calls.
LangChain (Python, langchain-openai):
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, extra_body={"flop": {"wait_for_settlement": False}}, ) print(llm.invoke("What does a GPU miner do?").content)
Vercel AI SDK, with @ai-sdk/openai-compatible (it calls chat completions, which floprouter offers; the Responses API is not offered):
import { generateText, streamText } 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, }); // fields under providerOptions.floprouter go into the request body const { text } = await generateText({ model: floprouter("qwen/qwen3-8b"), prompt: "In one sentence, what is a payment channel?", providerOptions: { floprouter: { flop: { wait_for_settlement: false } } }, });
An agent that needs tools can ask the model for a JSON action in plain text and parse it itself. That works today, because it is plain chat.
Editor tools and chat apps
Tools with an "OpenAI-compatible" provider setting take the base URL, key and model id above. Use chat, not agent or edit modes that rely on tool calls. Set the model's context and output limits low, since max_tokens sizes the escrow of every request.
MCP server
floprouter-mcp lets an agent list models and miners, run paid chat completions, and check sessions, balance and grant state. It never handles wallet keys.
Not published yet. The package is built and tested, but it is not on npm yet. The commands below work once it is published.
npx -y floprouter-mcp # stdio, what desktop and IDE clients use npx -y floprouter-mcp --http # streamable HTTP on http://127.0.0.1:8792/mcp
| Variable | Meaning |
|---|---|
FLOPROUTER_API_KEY | Your fr_... key. Without it, only the read-only tools work. Falls back to the key saved by floprouter login. |
FLOPROUTER_BASE_URL | Default https://api.floprouter.com |
| Tool | What it does | Paid |
|---|---|---|
list_models | Models, ready and reachable miners, escrow per 1,000 tokens | no |
list_miners | Miners with score, settle rate, sessions, strikes, calibration and reachability, with filters | no |
get_miner | One miner in detail | no |
chat | One chat completion, auto or pinned miner. Returns the reply, session id, miner, escrow and payer | yes |
session_status | Settlement state of a session | no |
account | Balance, deposit address, fee and grant state | no |
router_status | Network, sync state and payer | no |
Claude Code:
claude mcp add floprouter --scope user -e FLOPROUTER_API_KEY=fr_... -- npx -y floprouter-mcp
Claude Desktop (claude_desktop_config.json) and Cursor (~/.cursor/mcp.json):
{
"mcpServers": {
"floprouter": {
"command": "npx",
"args": ["-y", "floprouter-mcp"],
"env": { "FLOPROUTER_API_KEY": "fr_..." }
}
}
}Codex (~/.codex/config.toml):
[mcp_servers.floprouter] command = "npx" args = ["-y", "floprouter-mcp"] env = { FLOPROUTER_API_KEY = "fr_..." }
chat returns once the reply is verified. Use session_status for the settlement; many MCP clients time a tool out before a settlement would finish.
CLI
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 only receives your address, a signature over its login challenge, and transactions you sign, which go to the chain.
Not published yet. Same as the MCP server: the commands below work once the package is on npm. Needs Node 18.17 or later.
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 chat --miner <address> --stream "..." npx floprouter session <id>
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, builds the call itself, and refuses anything other than flopSessionKeys.createSession limited to ComputeChannel.
For agents reading this
- Every page of these docs is plain Markdown at its path plus
.md. /llms.txtis the index;/llms-full.txtis everything in one file./openapi.jsonis the machine-readable schema.