Flow AI in DeepSeek Harness
dsh ships a complete tool loop — web fetch, shell, files, sandbox, context compaction — and needs exactly one thing from outside: a model endpoint. Point it at Flow and its per-step router chooses among three routes on one key, while Flow's router picks the cheapest lane that completes each step and verifies the result.
Setup — five lines
llm-pi-ai:
providers:
flow:
apiKeyEnv: FLOWAI_API_KEY # your Flow key
api: openai-completions # streams tokens as they arrive
baseURL: https://api.flowaiapi.com/v1
models:
- id: flow-1 # balanced — the default
- id: flow-1-savings # max savings — cheapest capable lane
- id: flow-1-quality # quality first — best lane (add ensemble: true for two proposers + verifier pick)
compat:
supportsDeveloperRole: false
maxTokensField: max_tokens
agent-default-model:
provider: flow
model: flow-1The three ids are the three policies — the policy is the model name — so a harness can choose per step (savings for exploration, quality for the write-up) without a second key or a dashboard setting. Every response carries _flowaiapi: the lane used, the price paid, the routing candidates, the derived harness state and the verification verdict.
A real session, unedited
The question: “Look at buywhere.ai and its MCP server listings. Is it a good MCP server? Recommend how to test MCP servers.” What the harness did before any model wrote a word: read the site, the developer docs and the MCP endpoint; pulled the server's package.json, README, src/index.tsand its smoke-test script from GitHub; then ran the protocol itself — registered an account, initialised the MCP session, listed the tools, called one. The answer was a synthesis of ~120K tokens of evidence it had gathered. That is why it was good; the model was the cheapest lane that could hold the context.
| turn·step | tool | target | result | step time | lane (Flow) |
|---|---|---|---|---|---|
| 1·1 | web_fetch | buywhere.ai | 13 KB | 9.6 s | GLM Coding Max |
| 1·2 | web_fetch | buywhere.ai/developers | 4.6 KB | 13.2 s | GLM Coding Max |
| 1·3 | web_fetch | api.buywhere.ai/mcp | 0.7 KB | 9.6 s | GLM Coding Max |
| 1·4 | web_fetch | api.buywhere.ai/docs/guides/mcp | 9.6 KB | 12.9 s | GLM Coding Max |
| 1·5 | web_fetch | github.com/BuyWhere/buywhere-mcp | 4 KB | 13.3 s | GLM Coding Max |
| 1·6 | web_fetch | …/buywhere-mcp/main/package.json | 2.8 KB | 12.4 s | GLM Coding Max |
| 1·7 | web_fetch | …/buywhere-mcp/main/README.md | 19.1 KB | 8.6 s | GLM Coding Max |
| 1·8 | web_fetch | …/buywhere-mcp/main/src/index.ts | 5.3 KB | 11.2 s | GLM Coding Max |
| 1·9 | web_fetch | …/buywhere-mcp/main/scripts/smoke-tools.mjs | 3.7 KB | 35.1 s | GLM Coding Max |
| 1·10 | bash | curl POST api.buywhere.ai/v1/auth/register (registers an account, gets a key) | 0.2 KB | 15.7 s | GLM Coding Max |
| 1·11 | bash | curl POST api.buywhere.ai/mcp · initialize + tools/list | 27 KB | 16.4 s | GLM Coding Max |
| 1·12 | bash | curl POST api.buywhere.ai/mcp · tools/call | 19.7 KB | 78.0 s | GLM Coding Max |
| 1·13 | synthesis | turn failed here — a Flow bug, since fixed (see below) | — | 111.1 s | GLM Coding Max |
| 2·1 | bash | curl POST api.buywhere.ai/mcp · re-run with the key | 1.3 KB | 18.4 s | MiniMax-M3 |
| 2·2 | bash | curl POST api.buywhere.ai/mcp · tools/call | 15.9 KB | 13.1 s | MiniMax-M3 |
| 2·3 | synthesis | the answer — 43K tokens in, 2,476 out | — | 33.8 s | MiniMax-M3 |
Honesty note: turn 1 died at its final step. That was a Flow bug — the Responses stream could not serialise a value from one lane's pricing and closed the connection, which dsh reported as server_error: [object Object]. Fixed the same day; the recommended openai-completionssetting above also streams tokens progressively, which the Responses path does not.
What Flow adds to a harness
Routing on harness state
Each step is routed on the state of the loop — step index, tool failures, recovery loops, context pressure, the verifier's last verdict — derived by Flow when the harness does not send it, or sent explicitly as harness_state.
Verification on every step
A reward model we trained on execution truth scores each response (pass/fail with confidence, ~50 ms). Add ensemble: true on the quality route for two proposers and a verifier pick.
Price, not markup
Subscription, free-tier and marketplace supply at the lane's live price. The session above cost less than half a cent.