此页面仅提供英文版本。 以英文版本为准。
Deploying workloads
The full customer flow: choose an offer or let the scheduler pick, configure a template, fund the escrow on Base and follow the job to completion.
This page walks through every step of running a workload on MZGrid, from choosing hardware to stopping the job and getting the unused deposit back. The same flow is available in the marketplace, through the REST API and through the SDK.
1. Choose an offer — or let the scheduler choose
You have two options.
Pick an offer yourself. Browse the marketplace or call GET /v1/market/offers and filter by SKU, region, minimum VRAM and minimum reliability. Each offer shows the provider's tier, reliability, uptime over 30 days, completed jobs, benchmark score and the price per GPU-hour. Pass its id as offerId when creating the job.
Use autoSelect. Pass a sku and autoSelect: true. The scheduler considers every eligible offer for that SKU — VRAM at least the template minimum, provider active, and the job's deposit within the provider's job cap — and ranks them by:
score = 0.5 × normalizedPrice + 0.35 × (reliability / 100) + 0.15 × proximityPrice carries the most weight, but a cheap provider with poor reliability will lose to a slightly more expensive one with a strong track record.
2. Choose a template and configure it
Pick one of the templates. The config object lets you override the defaults:
| Field | Type | Used by |
|---|---|---|
model | string | vllm-openai — any Hugging Face model id, e.g. mistralai/Mistral-7B-Instruct-v0.3 |
image | string | custom-docker, batch — a public image reference, e.g. ghcr.io/acme/trainer:1.4 |
env | object | All templates — environment variables passed only to the container, e.g. HF_TOKEN |
ports | number[] | custom-docker — container ports to publish |
args | string[] | All templates — extra arguments appended to the container command, e.g. ["--max-model-len", "16384"] |
3. Choose a duration
maxDurationHours is the longest the job may run. It determines the deposit:
deposit = pricePerHour × maxDurationYou are billed only for the seconds the job actually runs, so it is safe to round up. The deposit must not exceed the provider's job cap (25 MZG + 4 × locked); if it does, the offer is not eligible for that duration. Choose a shorter duration or a provider with more locked collateral.
4. Create the job
From the website, click Deploy on the offer page. From the API:
curl -X POST https://api.mzgrid.io/v1/jobs \
-H "Authorization: Bearer $MZG_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"offerId": "off_9k2m4q7xw1",
"template": "llama-3.1-8b",
"maxDurationHours": 2,
"config": { "env": { "HF_TOKEN": "hf_..." } }
}'The response contains the job (status awaiting_funding) and the exact escrow parameters your wallet must submit. Do not change them: the coordinator only dispatches the job if the on-chain JobFunded event matches.
5. Connect your wallet and switch to Base
The website uses any injected EIP-1193 wallet. If the wallet is on another chain, the app requests a switch to Base (8453). You need MZG for the deposit and a small amount of ETH on Base for gas. Bridging and network details are documented at docs.base.org.
6. Fund the escrow
There are two ways to move the deposit into MZGridEscrow:
- Permit (recommended). You sign an EIP-2612 permit for exactly
depositWei— a signature, not a transaction — and submit a singlecreateJobWithPermittransaction. - Approve + create. You send
approve(escrow, depositWei)on the MZG token, thencreateJob. Two transactions, supported by every wallet.
After the transaction is mined, report it so the coordinator can verify the JobFunded event and dispatch the job (the website and jobs.fund() in the SDK do this automatically):
curl -X POST https://api.mzgrid.io/v1/jobs/job_7f3a9c2d41/funded \
-H "Authorization: Bearer $MZG_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "txHash": "0x5c1e...9b07" }'7. Follow the status
| Status | What is happening | Typical time in state |
|---|---|---|
awaiting_funding | Job created, escrow not funded yet. | Until you fund |
funded | Deposit is in escrow; the provider agent has been notified. | Seconds; at most 10 minutes |
starting | Provider accepted on-chain; image is being pulled and the container started. | 1–5 minutes depending on image and model size |
running | Container is up, usage is metered every 60 seconds, endpointUrl is set. | Up to maxDurationHours |
completed | Settled; charged amount and refund recorded in txs.settle. | Final |
Failure states are failed, cancelled and reclaimed — all three return the full deposit. See Billing & escrow.
提示
The accept clock starts at funding. If the job is still funded after 10 minutes, you can cancel it from the dashboard for a full refund and redeploy to another offer.
8. Use the endpoint and read logs
Inference templates set endpointUrl once the server is ready. OpenAI-compatible templates serve the API under /v1. Container output is streamed to the job's log:
curl "https://api.mzgrid.io/v1/jobs/job_7f3a9c2d41/logs?since=2026-11-04T09:12:00Z" \
-H "Authorization: Bearer $MZG_API_KEY"9. Stop early
Stop a job at any time from your dashboard or with POST /v1/jobs/:id/stop. The coordinator settles with the seconds used so far and the remainder of the deposit is refunded in the same transaction. Batch jobs stop on their own when the container exits; inference endpoints run until you stop them or maxDurationHours is reached.