Build

API reference

The Mason API follows the OpenAI Chat Completions format. Existing clients work by changing the base URL and key.

Authentication

Send your key as a bearer token: Authorization: Bearer mason_.... Without a key, /v1/chat/completions uses the free daily allowance (30 credits per visitor per day, paid by the treasury).

POST /v1/chat/completions

FieldTypeNotes
modelstringRequired. An id from GET /v1/models.
messagesarrayRequired. { role, content } with roles system, user, assistant.
streambooleanServer-sent events in the OpenAI chunk format, ending with data: [DONE]. Default false.
max_tokensinteger1 to 4096, default 1024. Enforced by the orchestrator: a worker that streams past it is cut off.
temperaturenumber0 to 2. Default 0.7.
top_pnumber0 to 1. Default 1.
stopstring or arrayUp to 4 stop sequences.

The response carries usage (tokens and credits charged) and a mason extension: the anonymous id of the worker that served the job, its runtime and its speed. Standard clients ignore it. Streaming responses also send an X-Mason-Worker header and put usage in the last chunk.

GET /v1/models

Lists the models with at least one trusted worker online right now.

{ "object": "list", "data": [
  { "id": "qwen2.5-1.5b-instruct", "object": "model", "owned_by": "mason", "class": "small", "workers": 1, "credits_per_1k_tokens": 0.2 }
] }

Other endpoints

EndpointWhat it does
POST /v1/keysCreates an account and a key (shown once). Five per address per day.
GET /v1/accountYour credits, usage, and the treasury address for deposits. Needs the key.
POST /v1/account/deposit{ "tx" }: the hash of an ETH transfer to the treasury whose data is the text mason:<account id>. Credits its dollar value at the on-chain ETH price, once.
GET /v1/catalogEvery model the network knows, with its browser and Ollama builds and live worker count.
GET /v1/networkLive network numbers, as shown on the Network page.
GET /v1/earnings/:walletA payout wallet's workers, and its unpaid, earned and paid amounts in dollars.
POST /v1/stakers/register{ wallet, signature } of the message Mason staking: register <wallet>.
GET /v1/stakers/:walletRegistration, counted stake, unpaid and earned amounts in dollars.

Errors

StatusCodeMeaning
400invalid_requestMalformed body or unknown field value.
401invalid_keyMissing, wrong or revoked key.
402insufficient_creditsNot enough credits for the request's maximum cost.
402free_allowance_usedNo key, and today's free allowance is used up.
404model_not_foundNo such model id.
429rate_limitedToo many keys created from this address today.
502worker_lostSent inside a stream: the worker dropped mid-answer. You were not charged.
503no_workerNo worker for this model right now, or none became free within 30 seconds.