---
name: shader
description: Use Shader to rent an NVIDIA GPU over SSH or Jupyter, generate image, video, voice or 3D files, and report costs from on-chain receipts using an agent key.
---

# Shader

Use the `shader` CLI or the MCP endpoint `https://api.shader.win/mcp`. Authenticate with the user-provided agent bearer token. Never print the token or commit it. `SHADER_TOKEN` overrides the CLI's saved login; `SHADER_API_URL` selects a local API.

## Before spending

1. Run `shader balance --json`, `shader agents --json` and `shader config --json`. Identify the current key from `shader whoami --json`. Read its request cap, day cap and spent today. Amount fields ending in `BaseUnits` are integers: 1,000 base units equal one credit.
2. Remaining day cap is the day cap minus spent today and any running work not yet settled. Check `shader instances --json` and `shader jobs --json`; include ongoing rentals and pending generations in your budget. The server performs the authoritative check, including work admitted concurrently.
3. Use config prices and `agentRentalMaxSeconds`. A rental is admitted against rate times that maximum duration, even when you intend to stop sooner. Do not invent prices or assume the displayed wallet balance is all spendable.
4. Prefer the smallest available GPU whose memory fits the workload. Check `shader gpus --json` before launch. A cap refusal is a reason to reduce scope or ask the wallet owner for a cap change, never to bypass the key with another payment path.

## Rentals

`shader rent <gpu-id> --ssh-key <public-key-path> --wait` returns an instance id. Record it immediately. `shader ssh <instance-id>` opens the system SSH client; Jupyter connection details are in the instance response.

Always run `shader stop <instance-id>` when finished, including after workload failure. Check the instance reaches `stopped`; `settling` means the final receipt is still pending. After a crash, recover with `shader instances --json`, identify your unfinished instances, and stop those you no longer need. Do not stop another key's work.

## Generation

Run `shader estimate <kind> <prompt> --json` with the same options you will pass to `shader generate`. Use `--seconds` for video and `--voice` for speech. Compare the estimate with wallet credits and both key caps before creating the job. `shader generate <kind> <prompt> --out <file>` waits for completion and saves the result. Use kind `asset3d` for 3D.

After work, run `shader receipts --json` and report the actual settled credits and transaction signature. Estimates and running meters are not final charges. Failed credit-funded generations are not charged; a failed prepaid x402 job may require an operator refund. Never retry an uncertain payment blindly.

## MCP

Send `Authorization: Bearer <agent-token>` to the streamable HTTP endpoint. Tools are `list_gpus`, `rent_gpu`, `get_instance`, `stop_gpu`, `get_balance`, `generate`, `get_job`, and `list_receipts`. Use `rent_gpu` arguments `gpu` and optional `ssh_public_key`; read the server's tool schemas for other arguments. MCP uses the same balances, reservations and caps as HTTP. Use the CLI estimate and agent reads before the MCP spending tools.

## Refusals

- `AGENT_CAP_EXCEEDED`: this request's estimate exceeds the key's request cap.
- `AGENT_DAILY_CAP_EXCEEDED`: current-day spend and unsettled work leave too little day cap.
- `CREDITS_TOO_LOW`: available wallet credits cannot cover headroom or the estimate; the wallet owner must top up or wait for outstanding work.
- `AGENT_TOKEN_INVALID`, `AGENT_TOKEN_REVOKED`, `AGENT_KEY_REVOKED`: stop using that credential and ask the owner for a valid key.
- `UNAUTHORIZED` on a signing route: a wallet session and signature are required. Agent tokens cannot build deposits, change keys, stake or submit wallet transactions.
