Start
Quickstart
Your first completion in under five minutes. If you already use the OpenAI SDK, you change two lines.
1. Get a key and credits
Open Account, create a key, and deposit ETH from your wallet (MetaMask or any EVM wallet): credits land as soon as the transfer confirms. Keys start with mason_ and are shown once. Store yours in an environment variable, never in source code.
The base URL is the address of the network server followed by /v1. On a server you run yourself, that is http://localhost:6390/v1.
export MASON_API_KEY="mason_..." export MASON_BASE_URL="http://localhost:6390/v1"
2. Call it with curl
curl "$MASON_BASE_URL/chat/completions" \
-H "Authorization: Bearer $MASON_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen2.5-1.5b-instruct",
"messages": [{ "role": "user", "content": "Explain WebGPU in one sentence." }]
}'A real answer from the network, served by a browser worker on an RTX 4060:
{ "object": "chat.completion", "model": "qwen2.5-1.5b-instruct",
"choices": [{ "message": { "role": "assistant", "content": "Sure! Here are three colors: red, blue, green." }, "finish_reason": "stop" }],
"usage": { "prompt_tokens": 9, "completion_tokens": 14, "total_tokens": 23, "credits": 0.0046 },
"mason": { "worker": "w_fd6a0125740053da", "runtime": "webgpu", "tokens_per_second": 56.7 } }3. Or with the OpenAI SDK
JavaScript:
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.MASON_API_KEY,
baseURL: process.env.MASON_BASE_URL,
});
const stream = await client.chat.completions.create({
model: "qwen2.5-1.5b-instruct",
messages: [{ role: "user", content: "Write a haiku about idle GPUs." }],
stream: true,
});
for await (const chunk of stream) process.stdout.write(chunk.choices[0]?.delta?.content ?? "");Python:
from openai import OpenAI
import os
client = OpenAI(api_key=os.environ["MASON_API_KEY"], base_url=os.environ["MASON_BASE_URL"])
r = client.chat.completions.create(
model="qwen2.5-1.5b-instruct",
messages=[{"role": "user", "content": "Name three open-weight model families."}],
)
print(r.choices[0].message.content)No key? Try the chat
The chat has two modes. Network sends your message to a worker GPU, with a small free daily allowance and no account. This GPU runs the model in your own tab through WebGPU, with nothing leaving your browser.