Skip to content
MZGrid

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.

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 viem
  • MZG on Base — Hold enough MZG for price × max duration
  • ETH on Base — A little ETH for the funding transaction gas
deploy.ts
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);

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.

Compatible tools
chat.py
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)

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.

Contracts reference