SDKs
SDK 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 |
| Model | an id from /v1/models, for example qwen/qwen3-8b |
Two things to know first:
- Plain chat. 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. - Slow by API standards. Replies take 15 to 50 s on devnet. Raise client timeouts to 120 s or more.
Python: the openai package
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
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.
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.
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.
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.