MinRate Developers Trading desk

Developer guide

Request a model at your price, inspect the order book, or bring your own inference server to the exchange.

Set MARKET_ORIGIN to the scheme, host and port of the market you opened. For the local preview, use http://127.0.0.1:8771.

API base path/v1

Send a chat completion

Sign in to the buyer desk, fund the prepaid wallet, and create a scoped key in API keys with permission to submit jobs. Set BUYER_KEY in your client environment. This example uses the OpenAI Python SDK, an exact trusted model ID in MODEL_ID, and a ceiling of eight US cents for one reply.

Python · OpenAI SDK
import os
from uuid import uuid4
from openai import OpenAI

client = OpenAI(
    base_url=os.environ["MARKET_ORIGIN"].rstrip("/") + "/v1",
    api_key=os.environ["BUYER_KEY"],
    timeout=130,
)
turn_id = str(uuid4())
reply = client.chat.completions.create(
    model=os.environ["MODEL_ID"],
    messages=[{"role": "user", "content": "What is a limit order?"}],
    extra_body={"max_price_cents": 8, "wait_seconds": 120},
    extra_headers={"Idempotency-Key": turn_id},
)
print(reply.choices[0].message.content)

Include earlier messages in subsequent turns. Each turn gets its own price cap and can match a different seller. Reuse the same idempotency key only when retrying the same turn. If the wait expires, the response includes a private job URL in the Location header.

Read prices and liquidity

The public order book includes exact model IDs, supply types, units, and aggregated bid and ask levels. Your authenticated model catalog is available at GET /v1/models.

PowerShell · curl
curl.exe -sS "$env:MARKET_ORIGIN/api/market"

# Set MODEL_ID to the exact community model ID from the book.
curl.exe -sS -G "$env:MARKET_ORIGIN/api/spot" `
  --data-urlencode "model=$env:MODEL_ID" `
  --data-urlencode "hours=24"
Trusted requests
Prices use US cents for one completed reply. The exchange operator manages the runner and can process the conversation. Sellers see prices and cannot read buyer messages or replies through the marketplace.
Community tokens
Prices use US cents per 1,000 combined input and output tokens. Set a maximum token rate and a total ceiling for each request.
Spot history
Realized trades for one exact community model within the chosen window. Current open offers appear in the order book.

Historical bids and asks

Use public GET /api/market/history to follow changes in quoted supply and demand. Supply the exact model ID from the order book and a window of 15m, 1h, 24h, or 7d.

PowerShell · one hour of quotes
curl.exe -sS -G "$env:MARKET_ORIGIN/api/market/history" `
  --data-urlencode "model=$env:MODEL_ID" `
  --data-urlencode "window=1h"

Timestamps use Unix seconds. Each entry in points records the best bid and ask and the total number of quotes across all price levels on each side. The events list shows changes in the number of quotes at individual price levels. Trusted models quote US cents per reply. Community models quote US cents per 1,000 combined tokens. For prices paid on completed token trades, use /api/spot.

Fund the wallet and read fees

Sign in with the primary account at the buyer or seller desk and open Wallet. Buyers prepay before placing orders. The exchange reserves the maximum job price, settles the final charge, and releases the unused balance. A request can fail with HTTP 402 when available funds or the key’s spending budget are insufficient.

Buyer prices include the exchange commission. Read the current rate in platform_fee_bps from the market configuration. Divide basis points by 100 to get the percentage. Each settled job credits the seller with the gross buyer charge less that job’s commission. External payment processor fees and model-provider charges are separate.

Check balance
GET /api/billing returns the account balance and payment mode. Practice funds have simulated value.
Buyer deposit
POST /api/billing/checkout accepts amount_cents from 500 to 25,000 and a unique request_key. In Stripe mode, the buyer completes checkout and the wallet credits the deposit after payment confirmation.
Seller payout
POST /api/billing/onboard starts payout setup. Once eligible, POST /api/billing/payout with a unique request_key requests the available whole-cent earnings. Reuse the same key to retry the same operation.

Billing endpoints require a primary account session. Keep funding and withdrawal in the human-operated wallet. Use scoped buyer and seller keys for API clients and MCP agents.

Submit a job and poll

Use asynchronous orders when you can wait for a match. Include a buyer bearer key on submission, status, and cancellation requests. The returned job ID belongs to the submitting buyer.

POST/api/buyer/jobs

For trusted execution, send model, messages, amount_cents, and auto_match. Set auto_match to false to compare offers before awarding the job.

POST/api/community/jobs

For token-priced jobs, a seller-managed host can inspect plaintext prompts and replies. Choose a key policy permitting seller hosts and explicitly set allow_seller_host to true when submitting the request. Replace the model ID below with one currently listed.

Community order · JSON body
{
  "model": "community/qwen2.5:7b",
  "messages": [{"role": "user", "content": "Explain a limit order."}],
  "rate_cents": 2,
  "max_price_cents": 5,
  "max_tokens": 64,
  "allow_seller_host": true
}

Save the JSON as order.json. The following PowerShell example submits it and polls the job. An open, unassigned job can be cancelled with POST /api/buyer/jobs/{id}/cancel and the body {}.

PowerShell · curl
$base = $env:MARKET_ORIGIN
$auth = "Authorization: Bearer $env:BUYER_KEY"
$turn = [guid]::NewGuid().ToString()
$order = curl.exe -sS "$base/api/community/jobs" `
  -H $auth -H "Content-Type: application/json" `
  -H "Idempotency-Key: $turn" --data-binary "@order.json" |
  ConvertFrom-Json

curl.exe -sS -H $auth "$base/api/buyer/jobs/$($order.job.id)"

Supply a model

Register each model server from the seller desk or with POST /api/seller/nodes using a seller key. Supply a label, the raw local model ID, a backend, and an ask in cents per 1,000 tokens.

Node registration · JSON body
{
  "label": "Local Ollama",
  "provider": "ollama",
  "model": "qwen2.5:7b",
  "rate_cents": 2
}

Store the one-time token from the registration response in the worker process environment as MARKET_WORKER_KEY. Launch the worker on the machine that runs the model. Buyers select the published ID with the community/ prefix.

Worker process · PowerShell
python node_worker.py --market $env:MARKET_ORIGIN `
  --backend ollama --endpoint http://127.0.0.1:11434 `
  --model qwen2.5:7b

For an OpenAI-compatible inference server, select openai-compatible and supply its endpoint. The worker reports measured token counts. Each worker uses its own node token. A seller account can manage multiple nodes and set a fixed ask, follow the market rate, or pause a listing.

Sellers are responsible for their right to supply the model, the provider terms that apply to their account, and the privacy and logging configuration of the host.

Connect an agent

Add the exchange to an MCP client that supports Streamable HTTP. Configure /mcp on your marketplace origin as the server URL and supply a buyer or seller bearer key through the client’s secret store.

POST/mcp

After initialization, use tools/list to discover the operations available to that key. Buyers can inspect the market and manage requests within their key’s spending limits. Sellers can manage supply. MCP has no funding or cash-out capability. A dedicated worker process handles node claims, inference, and results.