Developers
GPU compute as an API call.
Create jobs, fund escrow and get OpenAI-compatible endpoints programmatically. Everything you can do in the marketplace — and everything an autonomous agent needs — is available over REST and the TypeScript SDK.
REST API
JSON over HTTPS. Amounts are MZG decimal strings, timestamps ISO-8601.
TypeScript SDK
@mzgrid/sdk wraps the API, escrow funding and ABIs, fully typed.
Wallet & API keys
Sign in with any wallet, then issue mzg_live_ keys for servers.
Agent-ready
Agents can discover, fund and run compute without a human in the loop.
Quickstart
Deploy Llama 3.1 8B in a dozen lines.
The SDK handles job creation, the EIP-2612 permit and the createJob transaction, then waits for the provider to bring your endpoint up.
npm install @mzgrid/sdk viem— Install the SDK and viemMZG on Base— Hold enough MZG for price × max durationETH on Base— A little ETH for the funding transaction gas
import { CURRENT_TERMS_VERSION, MZGridClient } from "@mzgrid/sdk";
import { createWalletClient, custom } from "viem";
import { base } from "viem/chains";
const wallet = createWalletClient({ chain: base, transport: custom(window.ethereum!) });
// Wallet sign-in requires the Terms of Service version the user has explicitly accepted
const mzg = new MZGridClient({ apiUrl: "https://api.mzgrid.io", walletClient: wallet, termsVersion: CURRENT_TERMS_VERSION });
// 1. Let the scheduler pick the best RTX 4090 by price, reliability and proximity
const created = await mzg.jobs.create({
sku: "rtx4090",
autoSelect: true,
template: "llama-3.1-8b",
maxDurationHours: 4,
});
// 2. Deposit into escrow (EIP-2612 permit + createJob) — deposit = price × 4 h
await mzg.jobs.fund(created, wallet);
// 3. Wait for the OpenAI-compatible endpoint
const { endpointUrl } = await mzg.jobs.waitForEndpoint(created.job.id);
console.log("Ready:", endpointUrl);# Sign in once with your wallet, then create an API key in the dashboard
export MZG_API_KEY="mzg_live_..."
# Browse live offers: cheapest H100 SXM with reliability >= 95
curl -s "https://api.mzgrid.io/v1/market/offers?sku=h100-sxm&minReliability=95&sort=price&limit=5"
# Create a job — returns the escrow parameters to fund on Base
curl -s -X POST "https://api.mzgrid.io/v1/jobs" \
-H "Authorization: Bearer $MZG_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"sku": "h100-sxm",
"autoSelect": true,
"template": "llama-3.3-70b",
"maxDurationHours": 6,
"config": {}
}'
# After funding, report the transaction so the job is dispatched
curl -s -X POST "https://api.mzgrid.io/v1/jobs/$JOB_ID/funded" \
-H "Authorization: Bearer $MZG_API_KEY" \
-H "Content-Type: application/json" \
-d '{"txHash": "0x..."}'import os, time, requests
API = "https://api.mzgrid.io/v1"
H = {"Authorization": f"Bearer {os.environ['MZG_API_KEY']}"}
# Live GPU catalogue with availability and prices in MZG
for g in requests.get(f"{API}/catalog/gpus").json():
print(f"{g['name']:<24} {g['availableGpus']:>5} free from {g['lowestPrice']} MZG/h")
# Poll a job until its endpoint is ready
job_id = os.environ["JOB_ID"]
while True:
job = requests.get(f"{API}/jobs/{job_id}", headers=H).json()
if job["status"] == "running":
print("Endpoint:", job["endpointUrl"])
break
time.sleep(3)OpenAI-compatible
Point your existing client at your endpoint.
Inference templates run vLLM and expose /v1/chat/completions, /v1/completions and /v1/embeddings. Swap the base URL — LangChain, LlamaIndex and the OpenAI SDKs work unchanged.
from openai import OpenAI
# endpointUrl from GET /v1/jobs/:id once status == "running"
client = OpenAI(base_url=f"{endpoint_url}/v1", api_key=os.environ["VLLM_API_KEY"])
resp = client.chat.completions.create(
model="meta-llama/Llama-3.1-8B-Instruct",
messages=[{"role": "user", "content": "Summarise how MZGrid escrow works in two sentences."}],
max_tokens=200,
)
print(resp.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({ baseURL: `${endpointUrl}/v1`, apiKey: process.env.VLLM_API_KEY });
const stream = await client.chat.completions.create({
model: "meta-llama/Llama-3.1-8B-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 ?? "");API reference
Endpoints at a glance.
Base URL https://api.mzgrid.io/v1. Authenticate with Authorization: Bearer <token | key>.
Public
- GET
/v1/healthService status, chain id and indexed block - GET
/v1/catalog/gpusGPU catalogue with live availability and prices - GET
/v1/catalog/templatesWorkload templates and recommended GPUs - GET
/v1/market/offersLive offers — filter by sku, region, VRAM, reliability - GET
/v1/market/offers/:idOffer detail with price history and recent jobs - GET
/v1/network/statsNetwork totals and 24h figures - GET
/v1/network/timeseriesDaily series for gpuHours, jobs, providers, mzgSettled… - GET
/v1/network/regions · /sku-mix · /leaderboard · /activityGeography, GPU mix, top providers, live feed
Auth & keys
- POST
/v1/auth/nonceGet a sign-in message for a wallet address - POST
/v1/auth/verifyExchange an EIP-191 signature for a session token - POST
/v1/keysCreate an API key (mzg_live_…) - GET · DELETE
/v1/keys · /v1/keys/:idList or revoke API keys
Jobs & account
- POST
/v1/jobsCreate a job from an offer or with autoSelect; returns escrow parameters - POST
/v1/jobs/:id/fundedSubmit the funding tx hash; coordinator verifies JobFunded - GET
/v1/jobs · /v1/jobs/:idList jobs or fetch one with status, endpoint and txs - GET
/v1/jobs/:id/logsContainer logs since a timestamp - POST
/v1/jobs/:id/stopStop early — settles used seconds, refunds the rest - GET
/v1/accountMZG balance, escrowed amount, 30-day spend
Smart contracts on Base
MZGToken, MZGridEscrow and ProviderRegistry are verified on Basescan. Read every function, event and constant in the contracts reference.