{
  "openapi": "3.1.0",
  "info": {
    "title": "TensorGrid API",
    "version": "0.11.2",
    "description": "Multi-cloud GPU prices and pay-per-output AI, paid in USDG (0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168) on Robinhood Chain (4663) over x402. Every job gets a spend and policy check before payment is asked for. Check /api/v1/health for the state of each part."
  },
  "servers": [
    {
      "url": "https://api.tensorgrid.run"
    }
  ],
  "tags": [
    {
      "name": "Account"
    },
    {
      "name": "GPU"
    },
    {
      "name": "Outputs"
    },
    {
      "name": "Payments"
    },
    {
      "name": "Jobs"
    },
    {
      "name": "Meta"
    },
    {
      "name": "Project"
    },
    {
      "name": "Admin"
    }
  ],
  "paths": {
    "/api/v1/health": {
      "get": {
        "tags": [
          "Meta"
        ],
        "summary": "Health and the state of each component",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "version": {
                      "type": "string"
                    },
                    "mode": {
                      "type": "string"
                    },
                    "components": {
                      "type": "object",
                      "additionalProperties": {
                        "$ref": "#/components/schemas/ComponentStatus"
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Not ready",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "version": {
                      "type": "string"
                    },
                    "mode": {
                      "type": "string"
                    },
                    "components": {
                      "type": "object",
                      "additionalProperties": {
                        "$ref": "#/components/schemas/ComponentStatus"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/gpus": {
      "get": {
        "tags": [
          "GPU"
        ],
        "summary": "GPU market price ranges (weekly market price data, CC BY 4.0)",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tier",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "schema": {
              "enum": [
                "min",
                "median",
                "max",
                "providers"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Page size, 1 to 500",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "next_cursor from the previous page",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "gpus": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/GpuPrice"
                      }
                    },
                    "fetched_at": {
                      "type": "string"
                    },
                    "source": {
                      "type": "object"
                    },
                    "summary": {
                      "$ref": "#/components/schemas/GpuMarketSummary"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/gpu/summary": {
      "get": {
        "tags": [
          "GPU"
        ],
        "summary": "GPU counts in one place: GPU types tracked in the weekly market data, and GPU types with live offers (and how many are rentable under the price cap)",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "market": {
                      "$ref": "#/components/schemas/GpuMarketSummary"
                    },
                    "live": {
                      "$ref": "#/components/schemas/GpuLiveSummary"
                    },
                    "note": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/gpu/offers": {
      "get": {
        "tags": [
          "GPU"
        ],
        "summary": "Live on-demand GPU offers. Rent one with POST /api/v1/gpu/rentals",
        "parameters": [
          {
            "name": "gpu",
            "in": "query",
            "description": "GPU name contains, e.g. A4000",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "max_usd_per_hour",
            "in": "query",
            "description": "Max hourly price",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Page size, 1 to 500",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "next_cursor from the previous page",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "offers": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/GpuOffer"
                      }
                    },
                    "summary": {
                      "$ref": "#/components/schemas/GpuLiveSummary"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/gpu/quote": {
      "post": {
        "tags": [
          "GPU"
        ],
        "summary": "Price a GPU rental (provider hourly price + margin, for a fixed number of minutes). Runs the 2-of-3 checkers, no payment.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GpuRentalRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "quote": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Refused by the spend or policy check before any payment. Nothing charged.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "409": {
            "description": "Region not available or all GPU slots in use",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "GPU launch not enabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/gpu/rentals": {
      "post": {
        "tags": [
          "GPU"
        ],
        "summary": "Rent a GPU over x402. Without X-PAYMENT: checks, then 402 with payment requirements. With X-PAYMENT: verify payment, start the GPU (auto-deleted at the paid end time), receipt. The answer carries rental_token once.",
        "parameters": [
          {
            "name": "X-PAYMENT",
            "in": "header",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Optional. Same key + same request returns the stored answer (header Idempotent-Replayed: true) and never makes a second job. Kept 24 h.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GpuRentalRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Paid and finished. X-PAYMENT-RESPONSE header carries the settlement tx.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Checks passed. Pay with one of accepts[] and retry with X-PAYMENT.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentRequired"
                }
              }
            }
          },
          "403": {
            "description": "Refused by the spend or policy check before any payment. Nothing charged.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "409": {
            "description": "Region not available or all GPU slots in use",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Paid but the GPU could not be started (refund due)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "GPU launch not enabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/gpu/rentals/{job_id}": {
      "get": {
        "tags": [
          "GPU"
        ],
        "summary": "Rental status, SSH host and end time",
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Rental-Token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "GPU"
        ],
        "summary": "Stop a rental early (prepaid time is not refunded)",
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Rental-Token",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/models": {
      "get": {
        "tags": [
          "Outputs"
        ],
        "summary": "Model catalog: inputs, output type, per-output USDG price, example request",
        "parameters": [
          {
            "name": "category",
            "in": "query",
            "description": "Only one category",
            "schema": {
              "enum": [
                "image",
                "image-edit",
                "image-tools",
                "video",
                "audio",
                "speech-to-text",
                "3d"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "models": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Model"
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "categories": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "margin_bps": {
                      "type": "integer"
                    },
                    "prices_checked": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/models/{model}/stats": {
      "get": {
        "tags": [
          "Outputs"
        ],
        "summary": "Measured on TensorGrid runs: runs, succeeded, p50/p90 run time and success rate. Timing and rate are null until a model has at least 5 runs. No user data.",
        "parameters": [
          {
            "name": "model",
            "in": "path",
            "required": true,
            "schema": {
              "enum": [
                "flux-schnell",
                "z-image-turbo",
                "nano-banana",
                "nano-banana-2",
                "nano-banana-pro",
                "nano-banana-edit",
                "flux-kontext-pro",
                "bria-remove-background",
                "recraft-crisp-upscale",
                "bria-increase-resolution",
                "kling-2.5-turbo-pro-t2v",
                "kling-2.5-turbo-pro-i2v",
                "kling-2.5-turbo-std-i2v",
                "elevenlabs-tts-turbo-v2.5",
                "elevenlabs-tts-multilingual-v2",
                "minimax-speech-2.8-turbo",
                "elevenlabs-sound-effects-v2",
                "ace-step-music",
                "elevenlabs-scribe-v2",
                "trellis-image-to-3d"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/stats/public": {
      "get": {
        "tags": [
          "Status"
        ],
        "summary": "Aggregate proof: paid runs, receipts anchored, the newest anchor transaction, per-day counts for 14 UTC days and run counts per model (7d, 30d). No wallets, prompts or outputs.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/models/{model}": {
      "get": {
        "tags": [
          "Outputs"
        ],
        "summary": "One model: inputs, pricing and an example request",
        "parameters": [
          {
            "name": "model",
            "in": "path",
            "required": true,
            "schema": {
              "enum": [
                "flux-schnell",
                "z-image-turbo",
                "nano-banana",
                "nano-banana-2",
                "nano-banana-pro",
                "nano-banana-edit",
                "flux-kontext-pro",
                "bria-remove-background",
                "recraft-crisp-upscale",
                "bria-increase-resolution",
                "kling-2.5-turbo-pro-t2v",
                "kling-2.5-turbo-pro-i2v",
                "kling-2.5-turbo-std-i2v",
                "elevenlabs-tts-turbo-v2.5",
                "elevenlabs-tts-multilingual-v2",
                "minimax-speech-2.8-turbo",
                "elevenlabs-sound-effects-v2",
                "ace-step-music",
                "elevenlabs-scribe-v2",
                "trellis-image-to-3d"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "model": {
                      "$ref": "#/components/schemas/Model"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/policy": {
      "get": {
        "tags": [
          "Payments"
        ],
        "summary": "Spend policy for a payer (read only, no cap effect)",
        "parameters": [
          {
            "name": "payer",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/Address"
            }
          },
          {
            "name": "amount_usdc",
            "in": "query",
            "schema": {
              "type": "string",
              "example": "0.003"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/price": {
      "post": {
        "tags": [
          "Outputs"
        ],
        "summary": "Price preview without a wallet: same price as a quote, no payer, nothing stored, no cap effect.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model"
                ],
                "properties": {
                  "model": {
                    "enum": [
                      "flux-schnell",
                      "z-image-turbo",
                      "nano-banana",
                      "nano-banana-2",
                      "nano-banana-pro",
                      "nano-banana-edit",
                      "flux-kontext-pro",
                      "bria-remove-background",
                      "recraft-crisp-upscale",
                      "bria-increase-resolution",
                      "kling-2.5-turbo-pro-t2v",
                      "kling-2.5-turbo-pro-i2v",
                      "kling-2.5-turbo-std-i2v",
                      "elevenlabs-tts-turbo-v2.5",
                      "elevenlabs-tts-multilingual-v2",
                      "minimax-speech-2.8-turbo",
                      "elevenlabs-sound-effects-v2",
                      "ace-step-music",
                      "elevenlabs-scribe-v2",
                      "trellis-image-to-3d"
                    ]
                  }
                },
                "additionalProperties": true,
                "description": "model plus the same inputs as a quote (prompt, size, num_images, duration, ...). payer is not needed."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "preview": {
                      "const": true
                    },
                    "model": {
                      "type": "string"
                    },
                    "amount": {
                      "type": "string",
                      "description": "USDG base units (6 decimals)"
                    },
                    "amount_usdc": {
                      "type": "string"
                    },
                    "usd_list": {
                      "type": "number"
                    },
                    "quantity": {
                      "type": "number"
                    },
                    "unit": {
                      "type": "string"
                    },
                    "summary": {
                      "type": "string"
                    },
                    "price_basis": {
                      "type": "object"
                    },
                    "estimate": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/quote": {
      "post": {
        "tags": [
          "Outputs"
        ],
        "summary": "Quote and policy check. No cap effect, no payment asked.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JobRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "quote": {
                      "$ref": "#/components/schemas/Quote"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Refused by the spend or policy check before any payment. Nothing charged.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/quote/{quote_id}/commit": {
      "post": {
        "tags": [
          "Payments"
        ],
        "summary": "Commit to pay: payment guard (spend cap) check, returns payment requirements",
        "parameters": [
          {
            "name": "quote_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quote_token": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "quote": {
                      "$ref": "#/components/schemas/Quote"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Refused by the spend or policy check before any payment. Nothing charged.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "404": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "410": {
            "description": "Quote expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/x402/{model}": {
      "post": {
        "tags": [
          "Payments"
        ],
        "summary": "x402 resource: no X-PAYMENT -> checks + 402; with X-PAYMENT -> settle, run, receipt",
        "parameters": [
          {
            "name": "model",
            "in": "path",
            "required": true,
            "schema": {
              "enum": [
                "flux-schnell",
                "z-image-turbo",
                "nano-banana",
                "nano-banana-2",
                "nano-banana-pro",
                "nano-banana-edit",
                "flux-kontext-pro",
                "bria-remove-background",
                "recraft-crisp-upscale",
                "bria-increase-resolution",
                "kling-2.5-turbo-pro-t2v",
                "kling-2.5-turbo-pro-i2v",
                "kling-2.5-turbo-std-i2v",
                "elevenlabs-tts-turbo-v2.5",
                "elevenlabs-tts-multilingual-v2",
                "minimax-speech-2.8-turbo",
                "elevenlabs-sound-effects-v2",
                "ace-step-music",
                "elevenlabs-scribe-v2",
                "trellis-image-to-3d"
              ],
              "example": "flux-schnell"
            }
          },
          {
            "name": "X-PAYMENT",
            "in": "header",
            "schema": {
              "type": "string",
              "description": "base64 JSON {x402Version, scheme, network, payload}"
            }
          },
          {
            "name": "X-Payer",
            "in": "header",
            "schema": {
              "$ref": "#/components/schemas/Address"
            }
          },
          {
            "name": "X-Quote-Token",
            "in": "header",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Optional. Same key + same request returns the stored answer (header Idempotent-Replayed: true) and never makes a second job. Kept 24 h.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JobRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Paid and finished. X-PAYMENT-RESPONSE header carries the settlement tx.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Checks passed. Pay with one of accepts[] and retry with X-PAYMENT.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentRequired"
                }
              }
            }
          },
          "403": {
            "description": "Refused by the spend or policy check before any payment. Nothing charged.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/x402/verify": {
      "post": {
        "tags": [
          "Payments"
        ],
        "summary": "Verify an EIP-3009 payload against a quote without moving money",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "authorization",
                  "signature"
                ],
                "properties": {
                  "quote_id": {
                    "type": "string"
                  },
                  "quote_token": {
                    "type": "string"
                  },
                  "authorization": {
                    "$ref": "#/components/schemas/Authorization"
                  },
                  "signature": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "isValid": {
                      "type": "boolean"
                    },
                    "invalidReason": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "payer": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/jobs": {
      "post": {
        "tags": [
          "Jobs"
        ],
        "summary": "Settle a committed quote (tx_hash, or authorization + signature) and run it",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Optional. Same key + same request returns the stored answer (header Idempotent-Replayed: true) and never makes a second job. Kept 24 h.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quote_id": {
                    "type": "string"
                  },
                  "quote_token": {
                    "type": "string"
                  },
                  "tx_hash": {
                    "type": "string"
                  },
                  "authorization": {
                    "$ref": "#/components/schemas/Authorization"
                  },
                  "signature": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "402": {
            "description": "Payment not valid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "410": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/jobs/{job_id}": {
      "get": {
        "tags": [
          "Jobs"
        ],
        "summary": "One job. Private: the payer's session or API key, or a signed link (exp + sig, expires)",
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "exp",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Signed link expiry (unix seconds)"
          },
          {
            "name": "sig",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Signed link signature"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "404": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/receipts/{job_id}": {
      "get": {
        "tags": [
          "Jobs"
        ],
        "summary": "Receipt fields, keccak256 leaf (recomputed) and on-chain anchor. Private: the payer's session or API key, or a signed link (exp + sig).",
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "exp",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Signed link expiry (unix seconds)"
          },
          {
            "name": "sig",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Signed link signature"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/outputs/{job_id}/{n}": {
      "get": {
        "tags": [
          "Outputs"
        ],
        "summary": "Output file n of a finished job, served from this API (images, video, audio, 3D). Private: signed link (exp + sig) or the payer's session or API key",
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "n",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "exp",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Signed link expiry (unix seconds)"
          },
          {
            "name": "sig",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Signed link signature"
          }
        ],
        "responses": {
          "200": {
            "description": "The file (image/*, video/*, audio/*, model/*)"
          },
          "404": {
            "description": "No such job or file",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "410": {
            "description": "Output expired",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "502": {
            "description": "Output unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/images/generations": {
      "post": {
        "tags": [
          "Outputs"
        ],
        "summary": "Standard images API format over x402 (same 402 flow, standard response shape)",
        "parameters": [
          {
            "name": "X-PAYMENT",
            "in": "header",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Payer",
            "in": "header",
            "schema": {
              "$ref": "#/components/schemas/Address"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Optional. Same key + same request returns the stored answer (header Idempotent-Replayed: true) and never makes a second job. Kept 24 h.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "prompt"
                ],
                "properties": {
                  "prompt": {
                    "type": "string"
                  },
                  "model": {
                    "type": "string",
                    "default": "flux-schnell"
                  },
                  "n": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 4
                  },
                  "size": {
                    "enum": [
                      "512x512",
                      "1024x1024",
                      "1024x768"
                    ]
                  },
                  "user": {
                    "type": "string",
                    "description": "payer 0x address (or X-Payer header)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "created": {
                      "type": "integer"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "url": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Checks passed. Pay with one of accepts[] and retry with X-PAYMENT.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentRequired"
                }
              }
            }
          },
          "403": {
            "description": "Refused by the spend or policy check before any payment. Nothing charged.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Refusal"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/status": {
      "get": {
        "tags": [
          "Meta"
        ],
        "summary": "Same component view as health, always 200 (for status widgets)",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "version": {
                      "type": "string"
                    },
                    "mode": {
                      "type": "string"
                    },
                    "components": {
                      "type": "object",
                      "additionalProperties": {
                        "$ref": "#/components/schemas/ComponentStatus"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/config": {
      "get": {
        "tags": [
          "Meta"
        ],
        "summary": "Mode, chain, asset, site identity (base URL, X handle), token info",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/live": {
      "get": {
        "tags": [
          "Meta"
        ],
        "summary": "Liveness, always 200 while the process runs",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/livez": {
      "get": {
        "tags": [
          "Meta"
        ],
        "summary": "Liveness (for load balancers)",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/readyz": {
      "get": {
        "tags": [
          "Meta"
        ],
        "summary": "Readiness: 503 until config, store and keys are ready",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "503": {
            "description": "Not ready",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/healthz": {
      "get": {
        "tags": [
          "Meta"
        ],
        "summary": "Health (same as /api/v1/health)",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "503": {
            "description": "Not ready",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chain": {
      "get": {
        "tags": [
          "Meta"
        ],
        "summary": "Current Robinhood Chain block (read only)",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/quote/{quote_id}": {
      "get": {
        "tags": [
          "Outputs"
        ],
        "summary": "One quote (status, checks, price). The prompt is not returned.",
        "parameters": [
          {
            "name": "quote_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Quote-Token",
            "in": "header",
            "required": false,
            "description": "quote_token from POST /api/v1/quote. Send it so any server instance can return the quote.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "quote_token",
            "in": "query",
            "required": false,
            "description": "Same as the X-Quote-Token header",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "quote": {
                      "$ref": "#/components/schemas/Quote"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/receipts": {
      "get": {
        "tags": [
          "Jobs"
        ],
        "summary": "Your own receipts (session or API key), newest first. There is no public list.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "Page size, 1 to 500",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "next_cursor from the previous page",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "receipts": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Receipt"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "note": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Sign in or send an API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/receipts/verify/{leaf}": {
      "get": {
        "tags": [
          "Jobs"
        ],
        "summary": "Check a receipt by its hash: leaf recomputed and the anchor transaction read from the chain. Shows no wallet and no job id.",
        "parameters": [
          {
            "name": "leaf",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^0x[0-9a-fA-F]{64}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/milestones": {
      "get": {
        "tags": [
          "Project"
        ],
        "summary": "Roadmap phases and shippable features with status (done | in_progress | planned), completed_at and proof_url",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/openapi.json": {
      "get": {
        "tags": [
          "Meta"
        ],
        "summary": "This document",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/openapi.json": {
      "get": {
        "tags": [
          "Meta"
        ],
        "summary": "This document",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/health": {
      "get": {
        "tags": [
          "Meta"
        ],
        "summary": "Health (older path, use /api/v1/health)",
        "deprecated": true,
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/config": {
      "get": {
        "tags": [
          "Meta"
        ],
        "summary": "Config (older path, use /api/v1/config)",
        "deprecated": true,
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/chain": {
      "get": {
        "tags": [
          "Meta"
        ],
        "summary": "Chain block (older path, use /api/v1/chain)",
        "deprecated": true,
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/gpus": {
      "get": {
        "tags": [
          "GPU"
        ],
        "summary": "GPU prices (older path, use /api/v1/gpus)",
        "deprecated": true,
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/prices": {
      "get": {
        "tags": [
          "GPU"
        ],
        "summary": "GPU prices (older path, use /api/v1/gpus)",
        "deprecated": true,
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/models": {
      "get": {
        "tags": [
          "Outputs"
        ],
        "summary": "Models (older path, use /api/v1/models)",
        "deprecated": true,
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/quote": {
      "post": {
        "tags": [
          "Outputs"
        ],
        "summary": "Quote (older path, use /api/v1/quote)",
        "deprecated": true,
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/inference/{model}": {
      "post": {
        "tags": [
          "Outputs"
        ],
        "summary": "Quote for a model (older path, use /api/v1/quote)",
        "deprecated": true,
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/api/quote/{quote_id}/commit": {
      "post": {
        "tags": [
          "Payments"
        ],
        "summary": "Commit (older path, use /api/v1/quote/{quote_id}/commit)",
        "deprecated": true,
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "quote_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/api/commit": {
      "post": {
        "tags": [
          "Payments"
        ],
        "summary": "Commit (quote_id in body) (older path, use /api/v1/quote/{quote_id}/commit)",
        "deprecated": true,
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/jobs": {
      "post": {
        "tags": [
          "Jobs"
        ],
        "summary": "Settle and run (older path, use /api/v1/jobs)",
        "deprecated": true,
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Optional. Same key + same request returns the stored answer (header Idempotent-Replayed: true) and never makes a second job. Kept 24 h.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ]
      }
    },
    "/api/jobs/{job_id}": {
      "get": {
        "tags": [
          "Jobs"
        ],
        "summary": "One job (older path, use /api/v1/jobs/{job_id})",
        "deprecated": true,
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/api/x402/inference/{model}": {
      "post": {
        "tags": [
          "Payments"
        ],
        "summary": "x402 resource (older path, use /api/v1/x402/{model})",
        "deprecated": true,
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Optional. Same key + same request returns the stored answer (header Idempotent-Replayed: true) and never makes a second job. Kept 24 h.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ]
      }
    },
    "/api/v1/generate": {
      "post": {
        "tags": [
          "Payments"
        ],
        "summary": "x402 resource, model in body (older path, use /api/v1/x402/{model})",
        "deprecated": true,
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Optional. Same key + same request returns the stored answer (header Idempotent-Replayed: true) and never makes a second job. Kept 24 h.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ]
      }
    },
    "/api/gpu/offers": {
      "get": {
        "tags": [
          "GPU"
        ],
        "summary": "GPU offers (older path, use /api/v1/gpu/offers)",
        "deprecated": true,
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/deploy": {
      "post": {
        "tags": [
          "GPU"
        ],
        "summary": "GPU launch: restricted to the owner",
        "parameters": [
          {
            "name": "X-Owner-Token",
            "in": "header",
            "required": true,
            "description": "Owner token (the server stores only its sha256)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "No X-Owner-Token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Wrong owner token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "GPU launch is not open",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/instances": {
      "get": {
        "tags": [
          "GPU"
        ],
        "summary": "Owner: TensorGrid-tagged instances. Everyone else: empty list.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/instances/{id}": {
      "delete": {
        "tags": [
          "GPU"
        ],
        "summary": "Owner: delete one TensorGrid-tagged instance",
        "parameters": [
          {
            "name": "X-Owner-Token",
            "in": "header",
            "required": true,
            "description": "Owner token (the server stores only its sha256)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "No X-Owner-Token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Wrong owner token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/nonce": {
      "post": {
        "tags": [
          "Account"
        ],
        "summary": "Start wallet sign-in: returns the sign-in message (EIP-4361 style, chain 4663) to sign. No transaction, no gas.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "address"
                ],
                "properties": {
                  "address": {
                    "$ref": "#/components/schemas/Address"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "nonce": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "expires_at": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/verify": {
      "post": {
        "tags": [
          "Account"
        ],
        "summary": "Finish sign-in with the wallet signature (personal_sign). Returns a session token for Authorization: Bearer.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "nonce",
                  "signature"
                ],
                "properties": {
                  "nonce": {
                    "type": "string"
                  },
                  "signature": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "token": {
                      "type": "string"
                    },
                    "address": {
                      "$ref": "#/components/schemas/Address"
                    },
                    "expires_at": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Bad signature or expired nonce",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/session": {
      "delete": {
        "tags": [
          "Account"
        ],
        "summary": "Sign out (ends this session token)",
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/account": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "Balance (available and held), totals, open holds and deposit instructions",
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                }
              }
            }
          },
          "401": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Account"
        ],
        "summary": "Delete your account (signed-in session only). Refused while credits are held, a withdrawal is pending, a GPU rental is running, or any balance is left (withdraw first). Revokes API keys and deletes SSH keys and sessions. The ledger and invoices are kept for accounting under a random id without the wallet address.",
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "confirm"
                ],
                "properties": {
                  "confirm": {
                    "type": "string",
                    "enum": [
                      "DELETE"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "confirm_required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "session_required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "held_funds, withdrawal_pending, rental_active or balance_remaining",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/account/sample": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "Free sample status: whether this wallet can still take its one free run, and today's availability. Works without sign-in (eligible is then false).",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Account"
        ],
        "summary": "One free sample run per wallet, ever (signed-in session only), on a fixed cheap image model and size, paid by TensorGrid. Also limited to one per network per day and by a global daily budget. Recorded in the ledger as a sample entry with amount 0. Not unlimited.",
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "prompt"
                ],
                "properties": {
                  "prompt": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "400": {
            "description": "bad_prompt",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "session_required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "sample_used",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "sample_network_limit or samples_used_up (Free samples are used up for today)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "samples_off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/account/ledger": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "Append-only ledger, newest first, 100 entries per page",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "description": "Page number (older_page from the previous answer)",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "entries": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/LedgerEntry"
                      }
                    },
                    "page": {
                      "type": "integer"
                    },
                    "pages": {
                      "type": "integer"
                    },
                    "older_page": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/account/ledger.csv": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "Whole ledger as CSV",
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "CSV file",
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/account/invoices/{entry_id}": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "Invoice or receipt for one ledger entry (HTML, printable to PDF). ?format=json for the raw entry.",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "entry_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "format",
            "in": "query",
            "description": "json for the raw entry",
            "schema": {
              "enum": [
                "html",
                "json"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Invoice",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/account/deposits": {
      "post": {
        "tags": [
          "Account"
        ],
        "summary": "Add credits: send USDG from your signed-in wallet to pay_to on chain 4663, then submit the tx hash. Verified on chain, credited once.",
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "tx_hash"
                ],
                "properties": {
                  "tx_hash": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LedgerResult"
                }
              }
            }
          },
          "400": {
            "description": "Not a USDG transfer from this wallet to pay_to",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Already used, or not confirmed yet (retryable)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/account/jobs": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "Your own jobs and receipts (paid by this wallet, by credits or x402)",
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/account/runs": {
      "post": {
        "tags": [
          "Account"
        ],
        "summary": "Run a model and pay from credits in one call: quote, checkers, spend cap, hold, run, charge. A failed run releases the hold.",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Optional. Same key + same request returns the stored answer (header Idempotent-Replayed: true) and never makes a second job. Kept 24 h.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JobRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "400": {
            "description": "Bad or missing model inputs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "auth_required or invalid_token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "insufficient_credits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Refused by a check or an API key limit (key_daily_cap, key_disabled, keys_paused)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Run failed: status failed_refunded, nothing charged",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/account/refunds": {
      "post": {
        "tags": [
          "Account"
        ],
        "summary": "Move a failed on-chain paid run (status failed_refund_due) of this wallet into credits. Once per job.",
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "job_id"
                ],
                "properties": {
                  "job_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LedgerResult"
                }
              }
            }
          },
          "409": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/account/withdrawals": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "Your withdrawal requests",
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Account"
        ],
        "summary": "Ask to withdraw unused credits. The amount is held; the operator pays it on chain from pay_to, and the server marks it paid only after reading that transfer.",
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "amount_usdc"
                ],
                "properties": {
                  "amount_usdc": {
                    "type": "string",
                    "example": "1.5"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "bad_amount or below_minimum",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "insufficient_credits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "session_required: API keys cannot withdraw",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/account/withdrawals/{id}": {
      "delete": {
        "tags": [
          "Account"
        ],
        "summary": "Cancel a pending withdrawal (releases the hold)",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "409": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/account/ssh-keys": {
      "get": {
        "tags": [
          "Account",
          "GPU"
        ],
        "summary": "Your saved SSH public keys (offered when renting a GPU)",
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Account",
          "GPU"
        ],
        "summary": "Save an SSH public key (ssh-ed25519, ssh-rsa or ecdsa). At most 10.",
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "public_key"
                ],
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "public_key": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/account/ssh-keys/{id}": {
      "delete": {
        "tags": [
          "Account",
          "GPU"
        ],
        "summary": "Remove a saved SSH key",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/account/keys": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "API keys (never the secret)",
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Account"
        ],
        "summary": "Create an API key with a daily spend cap. The secret is returned once.",
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "daily_cap_usdc": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/account/keys/pause": {
      "post": {
        "tags": [
          "Account"
        ],
        "summary": "Kill switch for every key on the account ({paused: true|false})",
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "paused": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/account/keys/{id}": {
      "patch": {
        "tags": [
          "Account"
        ],
        "summary": "Switch a key off or on, change its daily cap or name",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "disabled": {
                    "type": "boolean"
                  },
                  "daily_cap_usdc": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Account"
        ],
        "summary": "Revoke a key (stops working at once)",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/account/gpu/rentals": {
      "get": {
        "tags": [
          "Account",
          "GPU"
        ],
        "summary": "Your GPU rentals paid from credits",
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Account",
          "GPU"
        ],
        "summary": "Rent a GPU from credits: needs at least 10 minutes of credit, holds up to max_minutes, bills per second, stops when the hold is used up, on Stop, or after idle_stop_minutes without a keep-alive. A GPU that fails to start is refunded in full.",
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "instance_type",
                  "cloud",
                  "region",
                  "ssh_public_key"
                ],
                "properties": {
                  "instance_type": {
                    "type": "string"
                  },
                  "cloud": {
                    "type": "string"
                  },
                  "region": {
                    "type": "string"
                  },
                  "ssh_public_key": {
                    "type": "string"
                  },
                  "max_minutes": {
                    "type": "integer"
                  },
                  "idle_stop_minutes": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "402": {
            "description": "insufficient_credits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "gpu_launch_unavailable (opens soon) or capacity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/account/gpu/rentals/{job_id}": {
      "get": {
        "tags": [
          "Account",
          "GPU"
        ],
        "summary": "Rental state, SSH and Jupyter connection, live meter",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Account",
          "GPU"
        ],
        "summary": "Stop now: charges the used seconds, releases the rest",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/account/gpu/rentals/{job_id}/keepalive": {
      "post": {
        "tags": [
          "Account",
          "GPU"
        ],
        "summary": "Keep-alive for the inactivity stop",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/.well-known/x402": {
      "get": {
        "tags": [
          "Meta"
        ],
        "summary": "x402 discovery: network, asset, schemes, resources",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/mcp": {
      "post": {
        "tags": [
          "Meta"
        ],
        "summary": "MCP server (Streamable HTTP, stateless, JSON-RPC)",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "Session token from /api/v1/auth/verify (tgs_...) or an API key (tgk_...)"
      }
    },
    "schemas": {
      "Account": {
        "type": "object",
        "properties": {
          "address": {
            "$ref": "#/components/schemas/Address"
          },
          "balance": {
            "type": "object",
            "properties": {
              "available": {
                "type": "string"
              },
              "available_usdc": {
                "type": "string"
              },
              "held": {
                "type": "string"
              },
              "held_usdc": {
                "type": "string"
              }
            }
          },
          "totals": {
            "type": "object"
          },
          "open_holds": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "keys_paused": {
            "type": "boolean"
          },
          "deposit": {
            "type": "object"
          }
        }
      },
      "LedgerEntry": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "seq": {
            "type": "integer"
          },
          "at": {
            "type": "string"
          },
          "type": {
            "enum": [
              "deposit",
              "hold",
              "spend",
              "release",
              "refund",
              "withdraw"
            ]
          },
          "amount": {
            "type": "string"
          },
          "amount_usdc": {
            "type": "string"
          },
          "available_after": {
            "type": "string"
          },
          "held_after": {
            "type": "string"
          },
          "ref": {
            "type": "string"
          },
          "tx_hash": {
            "type": "string"
          }
        }
      },
      "LedgerResult": {
        "type": "object",
        "properties": {
          "entry_id": {
            "type": "string"
          },
          "amount_usdc": {
            "type": "string"
          }
        }
      },
      "Address": {
        "type": "string",
        "pattern": "^0x[0-9a-fA-F]{40}$"
      },
      "ComponentStatus": {
        "type": "object",
        "required": [
          "status"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "operational",
              "degraded",
              "outage",
              "disabled",
              "scheduled",
              "restricted",
              "mock"
            ],
            "description": "operational: Running for real on this host. degraded: Running with a problem, or missing configuration it needs. outage: Not working right now. disabled: Built, and switched off on this host by configuration. scheduled: Not available yet; planned to be enabled. restricted: Available to the owner only. mock: Simulated (test mode only, never on the public host)."
          },
          "note": {
            "type": "string"
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error",
          "message"
        ],
        "description": "Every JSON error. Extra fields (checks, requirements, retryable, retry_after_s) depend on the error.",
        "properties": {
          "error": {
            "type": "string",
            "description": "stable machine code, e.g. quote_expired"
          },
          "message": {
            "type": "string"
          },
          "request_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "also in the X-Request-Id header"
          },
          "retryable": {
            "type": "boolean"
          }
        }
      },
      "Receipt": {
        "type": "object",
        "properties": {
          "job_id": {
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "amount": {
            "type": "string"
          },
          "amount_usdc": {
            "type": "string"
          },
          "payer": {
            "$ref": "#/components/schemas/Address"
          },
          "payee": {
            "$ref": "#/components/schemas/Address"
          },
          "payment_tx": {
            "type": "string"
          },
          "payment_explorer_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "completed_at": {
            "type": "string"
          },
          "leaf": {
            "type": "string"
          },
          "anchor": {
            "type": "object"
          },
          "mock": {
            "type": "boolean"
          },
          "sample_output": {
            "type": "boolean"
          }
        }
      },
      "Refusal": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "quote_id": {
            "type": "string"
          },
          "checks": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "note": {
            "type": "string"
          }
        }
      },
      "JobRequest": {
        "type": "object",
        "description": "Send the inputs the chosen model lists in GET /api/v1/models/{model}. Fields a model does not use are ignored. payer is required for x402 and quote calls; /api/v1/account/runs uses the signed-in wallet.",
        "properties": {
          "model": {
            "enum": [
              "flux-schnell",
              "z-image-turbo",
              "nano-banana",
              "nano-banana-2",
              "nano-banana-pro",
              "nano-banana-edit",
              "flux-kontext-pro",
              "bria-remove-background",
              "recraft-crisp-upscale",
              "bria-increase-resolution",
              "kling-2.5-turbo-pro-t2v",
              "kling-2.5-turbo-pro-i2v",
              "kling-2.5-turbo-std-i2v",
              "elevenlabs-tts-turbo-v2.5",
              "elevenlabs-tts-multilingual-v2",
              "minimax-speech-2.8-turbo",
              "elevenlabs-sound-effects-v2",
              "ace-step-music",
              "elevenlabs-scribe-v2",
              "trellis-image-to-3d"
            ],
            "default": "flux-schnell",
            "description": "Not needed on /api/v1/x402/{model}"
          },
          "payer": {
            "$ref": "#/components/schemas/Address"
          },
          "prompt": {
            "type": "string",
            "maxLength": 2000,
            "description": "Image, video, music and sound models"
          },
          "text": {
            "type": "string",
            "maxLength": 5000,
            "description": "Text to speech (prompt is accepted as an alias)"
          },
          "image_url": {
            "type": "string",
            "format": "uri",
            "description": "https URL. Image edit, upscale, cutout, image to video, image to 3D"
          },
          "audio_url": {
            "type": "string",
            "format": "uri",
            "description": "https URL. Speech to text"
          },
          "audio_seconds": {
            "type": "integer",
            "minimum": 1,
            "maximum": 7200,
            "description": "Speech to text: optional estimate. The server measures the real file length and bills per started minute"
          },
          "size": {
            "enum": [
              "square_hd",
              "square",
              "portrait_4_3",
              "portrait_16_9",
              "landscape_4_3",
              "landscape_16_9"
            ],
            "description": "Megapixel-priced image models"
          },
          "num_images": {
            "type": "integer",
            "minimum": 1,
            "maximum": 4
          },
          "aspect_ratio": {
            "type": "string"
          },
          "duration": {
            "description": "Video: '5' or '10'. Sound effects: 1-22. Music: 5-240 (seconds)",
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "integer"
              }
            ]
          },
          "voice": {
            "type": "string"
          },
          "scale": {
            "enum": [
              "2",
              "4"
            ]
          },
          "instrumental": {
            "enum": [
              "with vocals",
              "instrumental"
            ]
          }
        }
      },
      "Model": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "category": {
            "enum": [
              "image",
              "image-edit",
              "image-tools",
              "video",
              "audio",
              "speech-to-text",
              "3d"
            ]
          },
          "task": {
            "type": "string"
          },
          "summary": {
            "type": "string"
          },
          "output": {
            "type": "object",
            "properties": {
              "type": {
                "enum": [
                  "image",
                  "video",
                  "audio",
                  "text",
                  "model3d"
                ]
              },
              "description": {
                "type": "string"
              }
            }
          },
          "inputs": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "type": {
                  "enum": [
                    "text",
                    "url",
                    "enum",
                    "int"
                  ]
                },
                "required": {
                  "type": "boolean"
                },
                "label": {
                  "type": "string"
                },
                "options": {
                  "type": "array"
                },
                "min": {
                  "type": "number"
                },
                "max": {
                  "type": "number"
                },
                "default": {}
              }
            }
          },
          "pricing": {
            "type": "object",
            "properties": {
              "unit": {
                "type": "string"
              },
              "unit_label": {
                "type": "string"
              },
              "unit_price_usd": {
                "type": "number"
              },
              "unit_price_usdc": {
                "type": "string"
              },
              "billed_on": {
                "enum": [
                  "output",
                  "input"
                ]
              },
              "note": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "example_request": {
            "type": "object"
          },
          "example_quote": {
            "type": "object"
          },
          "price_checked": {
            "type": "string"
          }
        }
      },
      "Quote": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "quote_token": {
            "type": "string"
          },
          "amount": {
            "type": "string",
            "description": "USDG base units (6 decimals)"
          },
          "amount_usdc": {
            "type": "string"
          },
          "pay_to": {
            "$ref": "#/components/schemas/Address"
          },
          "payer": {
            "$ref": "#/components/schemas/Address"
          },
          "expires_at": {
            "type": "integer"
          },
          "status": {
            "type": "string"
          },
          "checks": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "Authorization": {
        "type": "object",
        "required": [
          "from",
          "to",
          "value",
          "validAfter",
          "validBefore",
          "nonce"
        ],
        "properties": {
          "from": {
            "$ref": "#/components/schemas/Address"
          },
          "to": {
            "$ref": "#/components/schemas/Address"
          },
          "value": {
            "type": "string"
          },
          "validAfter": {
            "type": "string"
          },
          "validBefore": {
            "type": "string"
          },
          "nonce": {
            "type": "string",
            "pattern": "^0x[0-9a-fA-F]{64}$"
          }
        }
      },
      "PaymentRequired": {
        "type": "object",
        "properties": {
          "x402Version": {
            "const": 1
          },
          "error": {
            "type": "string"
          },
          "accepts": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "scheme": {
                  "enum": [
                    "usdg-transfer",
                    "exact"
                  ]
                },
                "network": {
                  "const": "eip155:4663"
                },
                "asset": {
                  "const": "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168"
                },
                "maxAmountRequired": {
                  "type": "string"
                },
                "payTo": {
                  "$ref": "#/components/schemas/Address"
                },
                "resource": {
                  "type": "string"
                },
                "maxTimeoutSeconds": {
                  "type": "integer"
                },
                "extra": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "const": "Global Dollar"
                    },
                    "version": {
                      "const": "1"
                    },
                    "quote_id": {
                      "type": "string"
                    },
                    "quote_token": {
                      "type": "string"
                    },
                    "payer": {
                      "$ref": "#/components/schemas/Address"
                    },
                    "typed_data": {
                      "type": "object",
                      "description": "exact only: EIP-712 typed data to sign (EIP-3009 TransferWithAuthorization for USDG)"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "Job": {
        "type": "object",
        "properties": {
          "job_id": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "amount": {
            "type": "string"
          },
          "payment_tx": {
            "type": "string"
          },
          "payer": {
            "$ref": "#/components/schemas/Address"
          },
          "output": {
            "type": "object",
            "description": "type plus images[] | video | audio | text | model_mesh",
            "properties": {
              "type": {
                "type": "string"
              },
              "images": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              },
              "video": {
                "type": "object"
              },
              "audio": {
                "type": "object"
              },
              "text": {
                "type": "string"
              },
              "model_mesh": {
                "type": "object"
              },
              "sample": {
                "type": "boolean"
              }
            }
          },
          "receipt": {
            "type": "object"
          },
          "steps": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "GpuPrice": {
        "type": "object",
        "properties": {
          "label": {
            "type": "string"
          },
          "gpu": {
            "type": "string"
          },
          "min": {
            "type": "number"
          },
          "median": {
            "type": "number"
          },
          "max": {
            "type": "number"
          },
          "providers": {
            "type": "integer"
          }
        }
      },
      "GpuRentalRequest": {
        "type": "object",
        "required": [
          "payer",
          "instance_type",
          "cloud",
          "region",
          "ssh_public_key"
        ],
        "properties": {
          "payer": {
            "$ref": "#/components/schemas/Address"
          },
          "instance_type": {
            "type": "string",
            "example": "A4000"
          },
          "cloud": {
            "type": "string"
          },
          "region": {
            "type": "string"
          },
          "minutes": {
            "type": "integer",
            "description": "Paid run time; the GPU is deleted when it ends"
          },
          "ssh_public_key": {
            "type": "string",
            "description": "Installed on the machine so only you can log in"
          }
        }
      },
      "GpuMarketSummary": {
        "type": "object",
        "description": "Weekly market price data: a fixed list of tracked GPU types; providers are counted per GPU",
        "properties": {
          "week": {
            "type": "string"
          },
          "gpu_types_tracked": {
            "type": "integer"
          },
          "providers_max": {
            "type": "integer"
          },
          "providers_h100": {
            "type": "integer",
            "nullable": true
          },
          "stale": {
            "type": "boolean"
          },
          "label": {
            "type": "string"
          }
        }
      },
      "GpuLiveSummary": {
        "type": "object",
        "description": "Live cloud offers: counted over all offers, before any filter or page",
        "properties": {
          "offers": {
            "type": "integer"
          },
          "gpu_types": {
            "type": "integer"
          },
          "gpu_types_rentable": {
            "type": "integer"
          },
          "offers_rentable": {
            "type": "integer"
          },
          "clouds": {
            "type": "integer"
          },
          "cap_usd_per_hour": {
            "type": "number"
          },
          "fetched_at": {
            "type": "string"
          },
          "label": {
            "type": "string"
          }
        }
      },
      "GpuOffer": {
        "type": "object",
        "properties": {
          "gpu": {
            "type": "string"
          },
          "gpu_name": {
            "type": "string",
            "description": "Display name; GPU type counts group by this"
          },
          "num_gpus": {
            "type": "integer"
          },
          "cloud": {
            "type": "string"
          },
          "regions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "hourly_usd": {
            "type": "number"
          }
        }
      }
    }
  }
}