Kết nối tài khoản
Bạn đã có tài khoản EQVPS và muốn một script hoặc tác tử dùng nó: lấy token, đưa vào cấu hình, chạy sandbox đầu tiên và giữ số dư luôn đủ.
Mọi thứ khớp với nhau thế nào
1. Lấy token
Dễ nhất: trong bảng điều khiển mở Cài đặt → Token API, tạo một token (đặt tên theo tác tử, chọn thời hạn) và sao chép. Token chỉ hiện một lần.
Từ dòng lệnh: đăng nhập bằng email và mật khẩu để lấy token mới. Nếu bạn đăng ký bằng mã qua email và chưa từng đặt mật khẩu, hãy đặt một lần bằng token lấy từ bảng điều khiển. Bạn cũng có thể tạo tài khoản mới bằng POST /auth/register, lệnh này trả về token ngay.
# log in with email + password → token
curl -s https://api.eqvps.com/api/v1/eqvps/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"you@example.com","password":"your-password"}'
# → {"token":"eyJ0…","token_type":"Bearer","token_expires_at":"2027-10-03T…","user":{…}}
# signed up with an email code and have no password? set one once
# (authorise with a token from Settings → API tokens)
curl -s https://api.eqvps.com/api/v1/eqvps/auth/set-password \
-H "Authorization: Bearer $EQVPS_API_KEY" -H "Content-Type: application/json" \
-d '{"password":"new-pass-123","password_confirmation":"new-pass-123"}'
# no account yet: register straight from the API (password is optional)
curl -s https://api.eqvps.com/api/v1/eqvps/auth/register \
-H "Content-Type: application/json" -d '{"email":"you@example.com"}'
# extend a token before it expires
curl -s -X POST https://api.eqvps.com/api/v1/eqvps/auth/token/refresh \
-H "Authorization: Bearer $EQVPS_API_KEY"Token có hiệu lực 1 năm (xem token_expires_at trong phản hồi). Gia hạn bằng POST /auth/token/refresh; thu hồi những token không còn dùng trong Cài đặt.
2. Đưa vào cấu hình
Giữ token ngoài mã: export nó thành EQVPS_API_KEY. Các client MCP nhận nó trong header Authorization.
# shell / CI secret — keep it out of the code
export EQVPS_API_KEY="eyJ0…"
# SDKs read the same variable (0.2.0+: give your code its secrets as env, not in the source)
pip install -U eqvps # Python
npm i @eqvps/sdk@latest # TypeScript / JavaScript
# Claude Code
claude mcp add --transport http eqvps https://mcp.eqvps.com/mcp \
--header "Authorization: Bearer $EQVPS_API_KEY"
# Cursor, Claude Desktop, other MCP clients (mcp.json)
{
"mcpServers": {
"eqvps": {
"type": "streamable-http",
"url": "https://mcp.eqvps.com/mcp",
"headers": { "Authorization": "Bearer <YOUR_TOKEN>" }
}
}
}3. Chạy sandbox đầu tiên
Tạo, chạy mã, xóa. exit_code khác 0 là kết quả bình thường của lệnh, không phải lỗi HTTP.
API=https://api.eqvps.com/api/v1/eqvps
H="Authorization: Bearer $EQVPS_API_KEY"
SB=$(curl -s -X POST $API/sandboxes -H "$H" -H "Content-Type: application/json" \
-d '{"tariff":"micro"}' | python3 -c 'import sys,json; print(json.load(sys.stdin)["id"])')
curl -s -X POST $API/sandboxes/$SB/run -H "$H" -H "Content-Type: application/json" \
-d '{"language":"bash","code":"uname -sr && python3 --version && node --version"}'
# → {"exit_code":0,"stdout":"Linux 6.1…\nPython 3.12…\nv22…\n","stderr":"",…}
curl -s -X DELETE $API/sandboxes/$SB -H "$H"Chế độ, gói và ví dụ Python / Node.js: Sandbox →
4. Nạp tiền vào số dư
Sandbox và máy chủ được trả từ một số dư trả trước. Nạp trong bảng điều khiển (Số dư: tiền mã hóa, Monero hoặc mã khuyến mãi) hoặc bằng POST /balance/topup, lệnh này trả về liên kết thanh toán. GET /balance cho biết còn bao nhiêu.
curl -s $API/balance -H "$H"
# → {"balance":12.4,"currency":"USD","promo_balance":0,"real_balance":12.4,"promo_scope":"sandboxes"}
curl -s -X POST $API/balance/topup -H "$H" -H "Content-Type: application/json" -d '{"amount":10}'
# → {"invoice_id":…,"checkout_url":"https://…"} open the link and pay with cryptoCác lỗi bạn có thể gặp
- 401 Unauthenticated — thiếu token, gõ sai, hết hạn hoặc đã bị thu hồi. Kiểm tra header Authorization: Bearer, tạo token mới trong Cài đặt hoặc đăng nhập lại.
- 402 insufficient_balance — số dư trống nên không khởi động được sandbox mới. Nạp tiền rồi gửi lại yêu cầu. Sandbox bền vững đang chạy sẽ được tạm dừng chứ không bị xóa.
- 429 và 503 nghĩa là yêu cầu bị từ chối trước khi chạy bất cứ thứ gì: chờ Retry-After rồi gửi lại. 409 sandbox_paused: nạp tiền và sandbox chạy tiếp.
HTTP 401 {"message":"Unauthenticated."}
HTTP 402 {"error":"insufficient_balance","message":"Your balance cannot cover this sandbox. Top up (topup_balance / POST /balance/topup) and retry."}
HTTP 429 {"error":"too_many_concurrent", …} → wait Retry-After, then retry
HTTP 503 {"error":"capacity","retry_after":30, …} → wait Retry-After, then retry
Bình luận
Chưa có bình luận nào. Hãy là người đầu tiên.