---
name: rest
description: Run GPU inference on the REST network (restgpu.xyz), community home GPUs paid per verified job in USDC. Use when the user wants chat or text generation with Qwen2.5, text embeddings for search or RAG, image generation with Stable Diffusion, or text to speech, through REST, or mentions REST, restgpu.xyz, an idx_ API key, a Compute Pass, x402 GPU jobs or the REST MCP server. Covers the OpenAI-compatible API, the native jobs API with webhooks, x402 pay-per-job for agents, live prices and limits, and a zero-dependency CLI for quoting and running jobs.
---

# REST

> REST integration preview. API examples describe the intended interface; live REST service endpoints and client releases must be configured before use.

REST runs AI jobs on idle home GPUs. A second node re-runs a share of the jobs to check them, and a job is charged
only once it is verified; a job that fails or that no two nodes agree on is refunded. Payments go to the REST Holder
Vault in USDC on Elysium.

Base URL: `https://restgpu.xyz` (always `www`; the bare domain answers with a redirect).

## Pick the way in

| The code you are writing | Use | Auth |
|---|---|---|
| An app or script that already uses an OpenAI SDK, or any app | OpenAI-compatible API, base URL `https://restgpu.xyz/api/v1` | API key `idx_…` |
| A backend that wants a price cap per job, webhooks or long jobs | Native jobs API, `POST /api/network/jobs` | API key `idx_…` |
| An autonomous agent with its own wallet and no account | x402 per job, or the REST MCP server | the agent's wallet signs a USDC payment |

The user creates an API key on https://restgpu.xyz/build after topping up a Compute Pass. You cannot create one
for them: it takes their wallet's signature.

## Models today

| Kind | Model | Limits | Listed price |
|---|---|---|---|
| text | `qwen2.5-3b`, `qwen2.5-7b`, `qwen2.5-14b` | prompt up to 8,000 chars, system 2,000, max tokens 16 to 1,024 | 0.002 / 0.004 / 0.008 USDC per 1,000 tokens |
| embed | `nomic-embed-v1.5` | 1 to 32 texts of up to 2,000 chars, 32,000 in all; 768 dims | 0.0002 USDC per 1,000 tokens |
| image | `sd15` | 256 to 768 a side, steps of 64; 4 to 30 steps | 0.004 USDC for 512 × 512, 20 steps |
| image | `sdxl` | 768 to 1024 a side, steps of 64; 8 to 40 steps | 0.012 USDC for 1024 × 1024, 25 steps |
| voice (beta) | `kokoro-82m` | up to 600 chars of English; 8 voices; speed 0.8 to 1.5 | 0.002 USDC per 1,000 characters |
| 3D (beta) | `triposg` | one PNG or JPEG of one object, up to 500 kB; returns a textured GLB | 0.01 USDC per model |

Prices move: nodes ask 0.5× to 2× the listed price on the open market. Read the live list before you quote a number to
the user:

```bash
node scripts/rest.mjs models          # every model, listed price, nodes online now
```

A model with 0 nodes online fails at once with 503 `no_node_online`. Check before you build a feature around one, and
handle that error in the code you write.

## OpenAI-compatible API (default for apps)

```python
from openai import OpenAI
import os

client = OpenAI(base_url="https://restgpu.xyz/api/v1", api_key=os.environ["REST_API_KEY"])
r = client.chat.completions.create(model="qwen2.5-7b", messages=[{"role": "user", "content": "Hi"}], max_tokens=256)
print(r.choices[0].message.content)
```

```ts
import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://restgpu.xyz/api/v1", apiKey: process.env.REST_API_KEY });
const audio = await client.audio.speech.create({ model: "kokoro-82m", voice: "nova", input: "Hello from a home GPU.", response_format: "wav" });
```

Endpoints: `POST /v1/chat/completions`, `/v1/embeddings`, `/v1/images/generations`, `/v1/audio/speech`, and
`GET /v1/models`. Where it differs from OpenAI, write the code for REST, not for OpenAI:

- Decoding is greedy so a second node can repeat it. `temperature` and `top_p` are accepted and ignored; do not build
  "regenerate for variety" on it. Vary the prompt, or for images the `seed`.
- `max_tokens` is capped at 1,024. A conversation is sent to the model as one transcript.
- `stream: true` works but answers in one chunk once the text is ready.
- No tools, function calls, JSON mode or image input. Parse structured output from text yourself.
- Text to speech returns a 24 kHz WAV. OpenAI voice names map to Kokoro voices (alloy, echo, fable, onyx, nova,
  shimmer), or pass a Kokoro voice (`af_heart`, `af_bella`, `af_nicole`, `am_michael`, `am_fenrir`, `bf_emma`,
  `bm_george`, `bm_fable`). Split text longer than 600 characters into several requests.
- Each response carries the job: `rest` in the JSON (`job_id`, `status`, `price_usdc`), or `x-rest-job` and
  `x-rest-price-usdc` headers for audio. `status: "verifying"` means the answer arrived while a check runs; it is
  still charged only once verified.

Errors use OpenAI's shape. Handle them:

| Status | code | What to do |
|---|---|---|
| 401 | `invalid_api_key` | the key is missing, wrong or revoked |
| 402 | `insufficient_quota` | the Compute Pass is empty or the key's cap is reached; tell the user, do not retry |
| 404 | `model_not_found` | use a model from the table |
| 503 | `no_node_online` | nothing was filed or charged; fall back or retry later |
| 504 | (job id in the message) | no node answered in 120 s; the job keeps running, read it by id later |

## Native jobs API (price cap, webhooks)

`POST /api/network/jobs` with `Authorization: Bearer idx_…` and `{spec, prefer, maxPrice}`, then
`GET /api/network/jobs/{id}` until the status is `verified` (output in `output_url` or `output_text`) or `failed`,
`disputed` or `refunded`. `maxPrice` is in micro-USDC (4000 = 0.004 USDC) and refuses any offer above it. `prefer` is
`cheapest` or `fastest`. Specs, webhook signatures and x402 are in [reference/api.md](reference/api.md).

## Bring your own model (beta)

A builder can register a GGUF text model: `POST /api/network/models/byo` with the API key and
`{name, url, sha256}`, where `url` is one `.gguf` on huggingface.co at a pinned commit
(`https://huggingface.co/{org}/{repo}/resolve/{40-character commit}/{file}.gguf`) and `sha256` is the one Hugging
Face shows for it; up to 10 GB, no split files. It returns an id like `byo-74a4da8c9fdb`: use it as the `model` of a
text job or `/v1/chat/completions`. It is priced like the Qwen2.5 model of its size class. Nodes run it only after
their owner adds it, so it answers 503 `no_node_online` until one does; `GET /api/network/models/byo` lists every
model and its nodes online. Registering is free, but ask the user before registering on their behalf.

## Agents that pay for themselves

An agent with its own wallet pays per job over x402 and needs no key: `POST /api/network/x402/jobs` answers 402 with
the exact price, the agent signs a USDC transfer authorization for it and sends it again in `X-PAYMENT`. The REST MCP
server does this with hard spend caps; prefer it over hand-written signing. Setup:
https://restgpu.xyz/agents#toolkit

## The CLI in this skill

`scripts/rest.mjs` needs Node.js 18 or newer and nothing else.

```bash
node scripts/rest.mjs models                                   # free
node scripts/rest.mjs quote voice "Hello there"                # free: price and nodes online
node scripts/rest.mjs job 0x…                                  # free: status and output of a job
node scripts/rest.mjs run text "Write a haiku about GPUs" --max-usdc 0.005
node scripts/rest.mjs run image "a lighthouse at dusk" --model sd15 --out lighthouse.png
node scripts/rest.mjs run voice "Welcome back." --voice bf_emma --out welcome.wav
node scripts/rest.mjs run embed "first text" "second text" --out vectors.json
node scripts/rest.mjs run mesh chair.png --out chair.glb --max-usdc 0.02
```

`run` spends from the user's Compute Pass: it reads `REST_API_KEY` from the environment, quotes first, and refuses a
job above `--max-usdc` (default 0.01 USDC). Use it to check that a model is up and what it returns before you write
code around it.

## Rules

- **Ask before spending.** Free: `models`, `quote`, `job`, `GET /v1/models`, the market. Anything else runs a paid job.
  Run one only when the user asked for it or agreed, and say what it costs.
- **Keys stay out of code.** Read `REST_API_KEY` from the environment or the project's secret store. Never write a
  key into source, a commit, a log line or a client-side bundle; the browser must call your server, not REST, with it.
- **Never ask for a private key.** Wallets, top-ups, API keys and caps are the user's to handle on
  https://restgpu.xyz/build. An agent wallet for x402 is configured by the user in the MCP server's environment.
- **Suggest a cap.** A key can carry a spend cap per epoch; recommend one for anything that runs unattended.
- **Outputs are public.** The prompt of a key's job is shown only to that key's owner, but the output (text, image,
  audio) is stored by the network and shown in the public Explorer so anyone can check it, and nodes run by strangers
  see the prompt. Never send secrets or personal data, and tell the user this before they build on it.
- Facts here can go stale. When something disagrees with the live API, trust the API and the docs at
  https://restgpu.xyz/docs#api.
