Nhà phát triển
Tài nguyên GPU chỉ bằng một lệnh gọi API.
Tạo tác vụ, nạp ký quỹ và nhận endpoint tương thích OpenAI theo chương trình. Mọi thứ bạn có thể làm trên chợ GPU — và mọi thứ một agent tự hành cần — đều có qua REST và SDK TypeScript.
REST API
JSON qua HTTPS. Số tiền là chuỗi thập phân MZG, dấu thời gian theo ISO-8601.
SDK TypeScript
@mzgrid/sdk bao gói API, việc nạp ký quỹ và các ABI, định kiểu đầy đủ.
Ví & khóa API
Đăng nhập bằng bất kỳ ví nào, sau đó cấp khóa mzg_live_ cho máy chủ.
Sẵn sàng cho agent
Agent có thể tìm kiếm, nạp tiền và chạy tác vụ tính toán mà không cần con người can thiệp.
Bắt đầu nhanh
Triển khai Llama 3.1 8B chỉ với chục dòng mã.
SDK xử lý việc tạo tác vụ, permit EIP-2612 và giao dịch createJob, sau đó chờ nhà cung cấp khởi chạy endpoint cho bạn.
npm install @mzgrid/sdk viem— Cài đặt SDK và viemMZG trên Base— Có đủ MZG cho giá × thời lượng tối đaETH trên Base— Một ít ETH để trả gas cho giao dịch nạp tiền
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)Tương thích OpenAI
Trỏ client hiện có của bạn tới endpoint của bạn.
Các mẫu suy luận chạy vLLM và cung cấp /v1/chat/completions, /v1/completions và /v1/embeddings. Chỉ cần đổi base URL — LangChain, LlamaIndex và các SDK OpenAI hoạt động mà không cần thay đổi.
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 ?? "");Tham chiếu API
Tổng quan các endpoint.
Base URL https://api.mzgrid.io/v1. Xác thực bằng Authorization: Bearer <token | key>.
Công khai
- GET
/v1/healthTrạng thái dịch vụ, chain id và block đã lập chỉ mục - GET
/v1/catalog/gpusDanh mục GPU kèm mức sẵn có và giá trực tiếp - GET
/v1/catalog/templatesMẫu khối lượng công việc và GPU được khuyến nghị - GET
/v1/market/offersGói chào thuê trực tiếp — lọc theo sku, khu vực, VRAM, độ tin cậy - GET
/v1/market/offers/:idChi tiết gói chào thuê kèm lịch sử giá và tác vụ gần đây - GET
/v1/network/statsTổng số liệu mạng lưới và số liệu 24 giờ - GET
/v1/network/timeseriesChuỗi dữ liệu theo ngày cho gpuHours, jobs, providers, mzgSettled… - GET
/v1/network/regions · /sku-mix · /leaderboard · /activityĐịa lý, cơ cấu GPU, nhà cung cấp hàng đầu, luồng trực tiếp
Xác thực & khóa
- POST
/v1/auth/nonceLấy thông điệp đăng nhập cho một địa chỉ ví - POST
/v1/auth/verifyĐổi chữ ký EIP-191 lấy token phiên - POST
/v1/keysTạo khóa API (mzg_live_…) - GET · DELETE
/v1/keys · /v1/keys/:idLiệt kê hoặc thu hồi khóa API
Tác vụ & tài khoản
- POST
/v1/jobsTạo tác vụ từ một gói chào thuê hoặc với autoSelect; trả về tham số ký quỹ - POST
/v1/jobs/:id/fundedGửi hash giao dịch nạp tiền; bộ điều phối xác minh JobFunded - GET
/v1/jobs · /v1/jobs/:idLiệt kê tác vụ hoặc lấy một tác vụ kèm trạng thái, endpoint và các giao dịch - GET
/v1/jobs/:id/logsLog container kể từ một mốc thời gian - POST
/v1/jobs/:id/stopDừng sớm — quyết toán số giây đã dùng, hoàn lại phần còn lại - GET
/v1/accountSố dư MZG, số tiền đang ký quỹ, chi tiêu 30 ngày
Hợp đồng thông minh trên Base
MZGToken, MZGridEscrow và ProviderRegistry đã được xác minh trên Basescan. Xem mọi hàm, sự kiện và hằng số trong tài liệu tham chiếu hợp đồng.