API
API overview
The scheduler that hands out jobs, compares results and publishes payouts is served by this site under https://sparecycle.tech/api/v1. The full description is machine-readable: /api/v1/openapi.json (OpenAPI 3.1). Field-level shapes are also in docs/SPEC.md.
Conventions
- Format
- JSON in and out. Amounts are decimal strings in wei (they do not fit in a JSON number). Times are unix seconds.
- Errors
- Always
{ "error": "<code>", "message": "…" }with a kebab-case code, sometimes with extra fields (for examplefieldorretryAfter). Never a stack trace. - Prompts
- Never returned by any endpoint. Public lists carry a salted hash of the prompt instead.
- Caching
- Anything that depends on who asks (job detail, results, invoices, receipts, sign-in) is sent with
Cache-Control: private, no-store. - Trust
- One scheduler runs this API. It is centralized in this MVP; settled payouts on-chain cannot be changed afterwards.
Authentication
Most reads need nothing. The rest use one of these:
- Read secret
- Returned once by
POST /jobsasreadSecret; the scheduler stores only its hash. Send it asAuthorization: Bearer <readSecret>to read that job's result, invoice and receipt. Answers of the OpenAI-compatible routes and MCP carry the receipt path asreceipt_url, read with the same API key. - Wallet session
- Sign-In with Ethereum (EIP-4361), gasless:
GET /auth/nonce, sign the message with your wallet,POST /auth/verify. The answer sets an HttpOnly cookiesc_sessionfor 12 hours that reads the results, invoices and receipts of jobs this wallet paid for. - Payment signature
- A paid job carries an EIP-191 signature by the payer over the request and its price, valid for 10 minutes and for one job. See paid jobs over the API.
- Node signature
- The node client signs every request with its node key: headers
x-sc-from,x-sc-ts,x-sc-sigoversparecycle|METHOD|PATH|TS|sha256(body), 60-second window, each signature accepted once. - Operator token
- Bearer SCHEDULER_ADMIN_TOKEN, for the operator only. The endpoints answer 503 when none is configured.
Models, prices and capacity
GET /catalog (also /v1/catalog) needs no key. It lists exactly the models the scheduler runs, each with its label, kind, license and source, the live price per work unit, how units are counted, the request limits and live capacity: how many machines are ready now, how many are on standby in the project's GPU pool, and whether a pair with different owners can be reached. The Models page shows the same answer. The OpenAI-shaped /v1/models stays behind an API key.
capacity.pair"online": two machines with different owners are online."pool": none are, but the GPU pool can start a pair (the first job takes a minute or two).null: no pair can be reached now, and creating a job of this model answers503 no-node-pair(no_node_pairon/v1and MCP) with nothing queued, held or charged.network.operators"project-run"until a node of an outside owner passes the GPU gate and takes part in an agreed job. Today every node is run by the project: both owner wallets of a job then belong to the project.
curl -s https://sparecycle.tech/v1/catalogEndpoints
Generated from the same description as /api/v1/openapi.json, so the two cannot disagree. Paths are relative to /api/v1.
Jobs
Submit a job, follow its status, read its result.
GET /jobs
Recent jobs (prompt hashes only, never prompts)
Auth: none
POST /jobs
Submit a job: a free trial job, or a paid job from a prepaid balance
Auth: none
GET /jobs/{id}
A job's status, timestamps and parameters (never the prompt)
Auth: none or read secret or wallet session
GET /jobs/{id}/result
The result of an agreed job (image/png or text/plain), for its owner only
Auth: read secret or wallet session
HEAD /jobs/{id}/result
Same checks as GET, without the body
Auth: read secret or wallet session
GET /jobs/{id}/invoice
The private invoice of a paid or team job (a stub for a free trial job)
Auth: read secret or wallet session
GET /jobs/{id}/receipt
The payer's receipt of a paid or team job, checkable against the Charged event (a stub for a free trial job)
Auth: read secret or wallet session
GET /jobs/{id}/outputretired
Retired: use /jobs/{id}/result
Auth: none
HEAD /jobs/{id}/outputretired
Retired: use /jobs/{id}/result
Auth: none
Epochs
Six-hour payout periods: payout trees, Merkle proofs and charge lists.
GET /epochs
Every epoch the scheduler knows, newest first
Auth: none
GET /epochs/{id}/tree
The published payout tree of a closed epoch
Auth: none
GET /epochs/{id}/proof
Amount, leaf and Merkle proof for claim(epochId, amount, proof)
Auth: none
GET /epochs/{id}/charges
What an epoch's charge committed: per-customer totals and the jobs-tree leaves (v2), or the per-job list (v1)
Auth: none
Models
The public model catalog: what runs, what it costs per work unit, the limits and live capacity. No key.
GET /catalog
The model catalog: price per unit, how units are counted, limits and live capacity (no key)
Auth: none
Network
Scheduler status, nodes and health.
GET /health
Scheduler and database liveness
Auth: none
GET /status
Open epoch, node and job counters, last settled root, trust model
Auth: none
GET /nodes
Registered nodes: owner wallet, GPU, backend, online state
Auth: none
Payments
Prepaid balances in the SparecycleJobPayments contract.
GET /payments/account
A customer's balance, held amount, available amount, spend limit and pending withdrawal
Auth: none
Sign-in
Gasless wallet sign-in (EIP-4361) to read results of jobs the wallet paid for.
GET /auth/nonce
A single-use nonce for an EIP-4361 (Sign-In with Ethereum) message
Auth: none
POST /auth/verify
Check a signed EIP-4361 message and start a session
Auth: none
POST /auth/logout
End the session and clear the cookie
Auth: wallet session
Nodes (signed)
Called by the node client. Every request is signed by the node key.
POST /nodes/register
Register a node key, its owner wallet and its GPU
Auth: node signature
POST /nodes/poll
Long poll for a task (or a GPU challenge)
Auth: node signature
POST /nodes/heartbeat
Idle Guard: the state a node reports about its own machine
Auth: node signature
POST /tasks/{taskId}/result
Submit a task's signed result
Auth: node signature
POST /challenges/{id}/result
Submit the answer to a GPU challenge (unpaid, never a job)
Auth: node signature
Operator
Operator endpoints. Bearer SCHEDULER_ADMIN_TOKEN; 503 when none is configured.
POST /epochs/close
Close the open epoch and post its root (or retry an unposted root)
Auth: operator token
GET /admin/challenges
A node's GPU challenge state, recent challenges and the admin audit log
Auth: operator token
POST /admin/challenges
Re-issue a challenge, temporarily allow a node, or revoke that (audit-logged)
Auth: operator token
Meta
This API description.
GET /openapi.json
This API description (OpenAPI 3.1)
Auth: none
API keys
Spend-only keys per wallet: daily cap, kill switch, never withdraw. Managed with a wallet session.
GET /keys
List the signed-in wallet's API keys
Auth: wallet session
POST /keys
Create a pending API key and get its link message
Auth: wallet session
POST /keys/{id}/activate
Activate a pending key with the wallet's link signature; returns the full key once
Auth: wallet session
DELETE /keys/{id}
Delete a key (kill switch: queued jobs are cancelled and never charged)
Auth: wallet session
PATCH /keys/{id}
Relabel, lower or raise the daily cap, disable or re-enable a key
Auth: wallet session
POST /keys/disable-all
Disable every active key of the signed-in wallet
Auth: wallet session
OpenAI-compatible
Chat completions and image generations through the two-node check; asynchronous by default.
POST /chat/completions
Create a chat completion job (qwen2.5-1.5b); async, 202 by default
Auth: apiKey
GET /chat/completions/{id}
Poll a chat completion job (what chat.completions.retrieve calls)
Auth: apiKey
POST /images/generations
Create an image job (sd15); async, 202 by default
Auth: apiKey
GET /images/generations/{id}
Poll an image job (Sparecycle extension)
Auth: apiKey
GET /models
The two models
Auth: apiKey
MCP
Model Context Protocol server (Streamable HTTP, stateless) with four tools.
GET /mcp
Not offered (no standalone SSE stream)
Auth: none
POST /mcp
MCP server (Streamable HTTP, stateless, JSON answers)
Auth: apiKey
DELETE /mcp
Not offered (no sessions)
Auth: none
x402 pay-per-job
Internal review only — not externally audited
POST /v1/chat/completions without any Authorization header answers 402 with a PAYMENT-REQUIRED header when x402 is on, and 401 when it is off.An agent without an API key can pay for one job with x402 (version 2, scheme exact, an EIP-3009 signed transfer). The money is held in an escrow contract (source) until the two nodes have compared their results.
- 1. Ask
- Send the request without a key. The
402answer carries the price of this job (its work units times the price per work unit, in the payment asset's smallest unit), the asset, the network andpayTo: the escrow contract, never a wallet. A request above the escrow's per-job limit answers400 x402_amount_over_cap. - 2. Pay
- Sign a
TransferWithAuthorizationfor exactly that amount to the escrow (most x402 clients do this from thePAYMENT-REQUIREDheader) and send the same request again withPAYMENT-SIGNATURE. The scheduler checks the signature and moves the payment into the escrow from its own key; only then is the job queued. The202answer carriesPAYMENT-RESPONSE(the funding transaction) andsparecycle.read_secret. - 3. Poll
- Poll
sparecycle.pollwithAuthorization: Bearer <read_secret>. The secret is shown once; the paying wallet can also sign in to read the result. Sending the same payment again answers409 payment_used. - Outcome
- The two results match: the payment is forwarded, 95% for the node reward pot and 5% to the treasury. The reward pot pays ETH, so the pot share goes to a Safe-controlled address (a
Forwardedevent names it); converting it and adding it to the pot is a separate, manual Safe transaction. The results do not match, the job expires or is rejected: the whole payment is refunded. After the escrow's deadline anyone can callrefund, so a stopped scheduler cannot keep a payment. - Limits
- The escrow caps each payment, the total held at once and what one wallet can pay per epoch. The treasury Safe can change these limits, pause new payments and set the conversion address; it cannot move a held payment.
- Trust
- The scheduler key decides between forward and refund, as it decides verdicts today. Payments and their outcomes are public on-chain; at low volume their timing can link a paying wallet to a job in the public job list.
Limits
- Free trial jobs
- A few per IP address per hour; the current limit is in the
x-sc-rate-limitheader of everyPOST /jobsanswer. Over it:429 rate-limitedwithretryAfter. - Paid jobs
- Limited per paying wallet per hour, to protect the queue. Payment itself is the main guard.
- Result reads
- Rate limited per viewer: per job for a read secret, per wallet for a session, otherwise per IP address.
- Queue
- At most 500 open jobs at once; beyond that, 503 queue-full.
- No pair of nodes
- A job is created only when two nodes with different owners can take its model, online now or through the project's GPU pool. Otherwise
503 no-node-pairwithmodel(andretryAfterplus aRetry-Afterheader while the pool waits to try again): nothing is queued, held, counted against a limit or charged. - Job lifetime
- A job without a verdict after 6 hours expires and is not charged.
Try it
curl -s https://sparecycle.tech/api/v1/status
curl -s https://sparecycle.tech/api/v1/openapi.json -o sparecycle-openapi.json