Mercury 2 API, pay per call
Call Mercury 2 (inception/mercury-2) with an OpenAI-compatible request and pay per call in USDC on Base with x402. No API key, no account, no subscription; automatic refund if the model fails to answer.
Endpoint:
POST https://agent402-arb.rosariovitale0096.workers.dev/llm/mercury-2Model id:
inception/mercury-2 (fixed by the path; body.model can be omitted)Payment: x402 v2, USDC on Base, one payment per request, exact price in the 402 quote
Price: set per request from the live supplier cost; where the cost allows it the gateway charges less than BlockRun for the same request
How to call it
- POST your OpenAI-style request to
https://agent402-arb.rosariovitale0096.workers.dev/llm/mercury-2without payment. The answer is HTTP 402 with aPAYMENT-REQUIREDheader: the exact price in USDC for that prompt andmax_tokens(x402 v2, schemeexact, Base mainnet). - Sign the payment with any x402 client (EIP-3009
transferWithAuthorization; the wallet needs USDC on Base, no ETH). - Send the same request again with the
PAYMENT-SIGNATUREheader. You get a standardchat.completion. If the model fails to answer, the payment is refunded automatically.
// npm i @x402/core @x402/evm @x402/fetch viem
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { wrapFetchWithPayment } from "@x402/fetch";
import { privateKeyToAccount } from "viem/accounts";
const client = new x402Client();
registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.WALLET_KEY), networks: ["eip155:8453"] });
const pay = wrapFetchWithPayment(fetch, client);
const r = await pay("https://agent402-arb.rosariovitale0096.workers.dev/llm/mercury-2", { method: "POST", headers: { "content-type": "application/json" },
body: JSON.stringify({ messages: [{ role: "user", content: "Hello" }], max_tokens: 256 }) });
console.log((await r.json()).choices[0].message.content);
Quote only (free): curl -i -X POST https://agent402-arb.rosariovitale0096.workers.dev/llm/mercury-2 -H 'content-type: application/json' -d '{"messages":[{"role":"user","content":"Hello"}],"max_tokens":256}'
Limits
- max_tokens 1 to 16,384; up to 256 messages; request body up to 384 KB; no streaming.
- Function calling in OpenAI format (tools, tool_choice, tool results), passed through where the model supports it. Text only.
Machine-readable: OpenAPI, llms.txt, x402 manifest. Terms of use. The gateway is independent and not affiliated with any model provider; model names only identify the model that answers.