---
name: tensorgrid
description: Compare GPU cloud prices and buy AI outputs (images, video, speech, music, transcripts, 3D) paid in USDG on Robinhood Chain (chain 4663) over x402, with spend checks before every payment. Use when a user wants GPU price comparisons, live GPU offers, or a pay-per-output AI result paid from their own wallet.
---

# TensorGrid skill

TensorGrid gives you multi-cloud GPU prices and pay-per-output AI. Payment is USDG on Robinhood Chain over x402. No API key is needed: the user's own wallet pays, and you never ask for or handle private keys. If the user gives you a TensorGrid API key (starts with tgk_), you can pay from their prepaid credits instead with `POST /api/v1/account/runs` and `Authorization: Bearer tgk_...`, within the key's daily cap.

## Before you start

1. `GET /api/v1/health` and read `components`. Tell the user which parts are `operational` and which are `disabled`, `scheduled` or `restricted`. If `components.output.status` is not `operational`, paid AI runs are not enabled yet: quotes work, and run calls answer 503 `runs_opening_soon` before any payment.
2. Use the MCP server if you can (`POST /mcp`, Streamable HTTP, or `node mcp/index.js` with `TENSORGRID_API_URL`). Otherwise use the HTTP API below. Full reference: https://docs.tensorgrid.run and `/openapi.json`.

## GPU prices (read only)

- `GET /api/v1/gpus?q=h100&sort=min` (MCP: `list_gpu_prices`): price range per GPU type across providers, from the weekly market price data (CC BY 4.0). Credit the source when you show it.
- `GET /api/v1/gpu/offers` (MCP: `list_gpu_offers`): live on-demand offers. Offer to rent one only when `gpu_launch` is operational in `GET /api/v1/status` (MCP: `get_service_status`).
- `GET /api/v1/gpu/summary`: the GPU counts, from one place. `market.gpu_types_tracked` is the GPU types in the weekly market data; `live.gpu_types` is the GPU types with live offers now and `live.gpu_types_rentable` how many are under the rental price cap. Quote these numbers with their label and never mix them.

## Pick a model

- `GET /api/v1/models` (MCP: `list_models`, optional `category`: image, image-edit, image-tools, video, audio, speech-to-text, 3d). Each model lists its `inputs` (name, type, required, limits, default) and its price per unit.
- `GET /api/v1/models/{id}/stats` gives measured success rate and timing once a model has at least 5 runs (`enough_data`). Do not quote timing when it is null.
- `GET /api/v1/models/{id}` gives one model with an `example_request`. Send inputs as top-level fields next to `model` and `payer`, e.g. `prompt`, `text`, `image_url`, `audio_url` + `audio_seconds`, `size`, `num_images`, `aspect_ratio`, `duration`, `voice`.
- Bad inputs return 400 with `error` (e.g. `missing_input`, `bad_url`) and the `field`. URLs must be public https links.

## Buy one output

1. Show the price first: `POST /api/v1/quote` with `{model, payer, ...inputs}` (MCP: `get_quote`). Quotes do not touch the spend cap.
2. Get the user's OK for the exact USDG amount. Then `POST /api/v1/x402/{model}` with `{payer, ...inputs}` (MCP: `pay_and_run` without `payment`). The payment guard now counts this amount toward the payer's cap.
   - 403 means the spend check refused. Nothing was charged. Tell the user the reason, do not retry around it.
   - 402 gives `accepts[]`.
3. Pay with the user's wallet:
   - Preferred `exact` (EIP-3009): have the wallet sign `accepts[scheme=exact].extra.typed_data` (a USDG `TransferWithAuthorization`) with `eth_signTypedData_v4`. The wallet needs USDG only; our relayer pays the ETH gas. Only offered when the host has settlement on (check `/.well-known/x402` `schemes`).
   - Or `usdg-transfer`: the wallet sends exactly `maxAmountRequired` USDG to `payTo` and you keep the tx hash.
4. Retry with `X-PAYMENT` (MCP: `pay_and_run` with `quote_token`, `payment` and an `idempotency_key`). Include `quote_token`. Send the same `Idempotency-Key` on every retry so a retry never makes a second job.
   - Step by step instead of x402: `get_quote` -> `commit_quote` -> wallet pays -> `submit_payment` (HTTP: `POST /api/v1/quote/{id}/commit`, then `POST /api/v1/jobs`).
   - `retryable: true` (tx not mined yet, settlement in progress) means wait a few seconds and retry the same call.
5. Show the result and its receipt from the signed `links.receipt_url` in the run answer (MCP: `get_receipt` with `job_id`, `exp`, `sig`). Runs are private: a bare job id opens nothing, and signed links expire after 7 days. `GET /api/v1/receipts` with the user's API key (MCP: `list_receipts`) lists their own receipts; receipts are private. Anyone can check a receipt hash with `GET /api/v1/receipts/verify/{leaf}`.

## Rules for agents

- Never ask for, store or print a private key or seed phrase. Signing happens in the user's wallet.
- Always show the USDG amount and get a yes before step 2.
- Check `GET /api/v1/policy?payer=0x...` (MCP: `check_spend_policy`) if the user asks about limits. The live Guard has no read endpoint, so remaining cap may be unknown.
- A paid job that fails is `failed_refund_due`. Refunds are manual in v1. Say so plainly.
- Errors are `{error, message, request_id}`. Show `message` to the user.
- Asset is USDG `0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168` (6 decimals). Network `eip155:4663`.
