Pular para o conteúdo
MZGrid

Esta página está disponível apenas em inglês. A versão em inglês é a que prevalece.

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:

Texto
score = 0.5 × normalizedPrice + 0.35 × (reliability / 100) + 0.15 × proximity

Price 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:

FieldTypeUsed by
modelstringvllm-openai — any Hugging Face model id, e.g. mistralai/Mistral-7B-Instruct-v0.3
imagestringcustom-docker, batch — a public image reference, e.g. ghcr.io/acme/trainer:1.4
envobjectAll templates — environment variables passed only to the container, e.g. HF_TOKEN
portsnumber[]custom-docker — container ports to publish
argsstring[]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:

Texto
deposit = pricePerHour × maxDuration

You 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:

Shell
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 single createJobWithPermit transaction.
  • Approve + create. You send approve(escrow, depositWei) on the MZG token, then createJob. 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):

Shell
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

StatusWhat is happeningTypical time in state
awaiting_fundingJob created, escrow not funded yet.Until you fund
fundedDeposit is in escrow; the provider agent has been notified.Seconds; at most 10 minutes
startingProvider accepted on-chain; image is being pulled and the container started.1–5 minutes depending on image and model size
runningContainer is up, usage is metered every 60 seconds, endpointUrl is set.Up to maxDurationHours
completedSettled; 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.

Dica

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:

Shell
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.