{
  "openapi": "3.1.0",
  "info": {
    "title": "Tensorate GPU-hour price index API",
    "version": "1.0.0",
    "description": "Read-only API for the Tensorate GPU-hour price index. No authentication. CORS open. Data updates every 5 minutes. Limit: 120 requests per minute per IP."
  },
  "servers": [
    {
      "url": "https://tensorate.xyz"
    }
  ],
  "paths": {
    "/v1/index": {
      "get": {
        "summary": "Latest index for every GPU",
        "operationId": "getIndex",
        "responses": {
          "200": {
            "description": "Latest index",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Index"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "No data collected yet",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/history/{gpu}": {
      "get": {
        "summary": "Price history for one GPU",
        "operationId": "getHistory",
        "parameters": [
          {
            "name": "gpu",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/GpuId"
            }
          },
          {
            "name": "range",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "24h",
                "7d",
                "30d",
                "90d"
              ],
              "default": "7d"
            },
            "description": "24h: raw 5-minute points; 7d: 1-hour buckets; 30d: 4-hour buckets; 90d: 12-hour buckets"
          }
        ],
        "responses": {
          "200": {
            "description": "History points",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/History"
                }
              }
            }
          },
          "400": {
            "description": "Invalid range",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Unknown GPU id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/gpus": {
      "get": {
        "summary": "GPU catalog",
        "operationId": "getGpus",
        "responses": {
          "200": {
            "description": "Catalog",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "headline": {
                      "$ref": "#/components/schemas/GpuId"
                    },
                    "gpus": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CatalogGpu"
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/health": {
      "get": {
        "summary": "Liveness",
        "operationId": "health",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/fit": {
      "get": {
        "summary": "Cheapest GPU setups that can serve a model",
        "operationId": "fitModel",
        "parameters": [
          {
            "name": "model",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Model id from /v1/models. Required unless gb is given."
          },
          {
            "name": "quant",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "fp16",
                "fp8",
                "int8",
                "int4"
              ],
              "default": "fp16"
            }
          },
          {
            "name": "ctx",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 8192,
              "minimum": 256
            }
          },
          {
            "name": "batch",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 1,
              "minimum": 1,
              "maximum": 256
            }
          },
          {
            "name": "gb",
            "in": "query",
            "schema": {
              "type": "number"
            },
            "description": "Raw memory need in GB, instead of model"
          }
        ],
        "responses": {
          "200": {
            "description": "Memory estimate and setups",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "model": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "quant": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "ctx": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "batch": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "needGb": {
                      "type": "object",
                      "properties": {
                        "weights": {
                          "type": "number"
                        },
                        "kv": {
                          "type": "number"
                        },
                        "total": {
                          "type": "number"
                        }
                      }
                    },
                    "updatedAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "setups": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "gpu": {
                            "$ref": "#/components/schemas/GpuId"
                          },
                          "label": {
                            "type": "string"
                          },
                          "count": {
                            "type": "integer"
                          },
                          "vram": {
                            "type": "number"
                          },
                          "perHour": {
                            "type": "number"
                          },
                          "perMonth": {
                            "type": "number"
                          },
                          "available": {
                            "type": [
                              "integer",
                              "null"
                            ]
                          },
                          "rentableNow": {
                            "type": [
                              "boolean",
                              "null"
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad model, quant or gb",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "No data yet",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/models": {
      "get": {
        "summary": "Models known to /v1/fit",
        "operationId": "getModels",
        "responses": {
          "200": {
            "description": "Models",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "models": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "label": {
                            "type": "string"
                          },
                          "params": {
                            "type": "number",
                            "description": "billions"
                          }
                        }
                      }
                    },
                    "quant": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/candles/{gpu}": {
      "get": {
        "summary": "OHLC candles for one GPU from index history",
        "operationId": "getCandles",
        "parameters": [
          {
            "name": "gpu",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/GpuId"
            }
          },
          {
            "name": "interval",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "5m",
                "1h",
                "4h",
                "1d"
              ],
              "default": "1h"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Candles",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "gpu": {
                      "type": "string"
                    },
                    "interval": {
                      "type": "string"
                    },
                    "candles": {
                      "type": "array",
                      "description": "[t_ms, open, high, low, close, samples]",
                      "items": {
                        "type": "array",
                        "items": {
                          "type": "number"
                        },
                        "minItems": 6,
                        "maxItems": 6
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad interval",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Unknown GPU",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/oracle": {
      "get": {
        "summary": "On-chain oracle on Robinhood Chain",
        "operationId": "getOracle",
        "description": "Where the index is published on-chain (TensorateOracle, chain id 4663). Prices have 6 decimals; a push happens on a 1% move, a new GPU, or hourly.",
        "responses": {
          "200": {
            "description": "Oracle status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "chain": {
                      "type": "string"
                    },
                    "chainId": {
                      "type": "integer"
                    },
                    "address": {
                      "type": "string",
                      "nullable": true
                    },
                    "live": {
                      "type": "boolean"
                    },
                    "decimals": {
                      "type": "integer"
                    },
                    "deviation": {
                      "type": "number"
                    },
                    "heartbeatSeconds": {
                      "type": "integer"
                    },
                    "source": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/token/stats": {
      "get": {
        "summary": "Token market stats (DexScreener)",
        "operationId": "getTokenStats",
        "responses": {
          "200": {
            "description": "Pair stats",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "token": {
                      "type": "string"
                    },
                    "pair": {
                      "type": "string"
                    },
                    "priceUsd": {
                      "type": "number",
                      "nullable": true
                    },
                    "priceNative": {
                      "type": "number",
                      "nullable": true
                    },
                    "marketCap": {
                      "type": "number",
                      "nullable": true
                    },
                    "fdv": {
                      "type": "number",
                      "nullable": true
                    },
                    "liquidityUsd": {
                      "type": "number",
                      "nullable": true
                    },
                    "volume24h": {
                      "type": "number",
                      "nullable": true
                    },
                    "change": {
                      "type": "object",
                      "properties": {
                        "m5": {
                          "type": "number",
                          "nullable": true
                        },
                        "h1": {
                          "type": "number",
                          "nullable": true
                        },
                        "h6": {
                          "type": "number",
                          "nullable": true
                        },
                        "h24": {
                          "type": "number",
                          "nullable": true
                        }
                      }
                    },
                    "txns24h": {
                      "type": "object",
                      "properties": {
                        "buys": {
                          "type": "number",
                          "nullable": true
                        },
                        "sells": {
                          "type": "number",
                          "nullable": true
                        }
                      }
                    },
                    "pairCreatedAt": {
                      "type": "number",
                      "nullable": true
                    },
                    "url": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Upstream unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Token not launched yet",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/token/ohlcv": {
      "get": {
        "summary": "Token candles from on-chain swaps",
        "operationId": "getTokenOhlcv",
        "parameters": [
          {
            "name": "tf",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "5m",
                "15m",
                "1h",
                "4h",
                "1d"
              ],
              "default": "15m"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Candles in USD: [t_ms, open, high, low, close, volumeUsd]",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "pair": {
                      "type": "string"
                    },
                    "tf": {
                      "type": "string"
                    },
                    "source": {
                      "type": "string"
                    },
                    "candles": {
                      "type": "array",
                      "items": {
                        "type": "array",
                        "items": {
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad timeframe",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "ETH price unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Token not launched yet",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/token/supply": {
      "get": {
        "summary": "Token supply read from the contract",
        "operationId": "getTokenSupply",
        "responses": {
          "200": {
            "description": "Supply in whole tokens",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "token": {
                      "type": "string"
                    },
                    "chain": {
                      "type": "string"
                    },
                    "decimals": {
                      "type": "integer"
                    },
                    "maxSupply": {
                      "type": "number"
                    },
                    "mintable": {
                      "type": [
                        "boolean",
                        "null"
                      ]
                    },
                    "burnWallet": {
                      "type": "string"
                    },
                    "minted": {
                      "type": "number"
                    },
                    "burned": {
                      "type": "number"
                    },
                    "total": {
                      "type": "number"
                    },
                    "circulating": {
                      "type": "number"
                    },
                    "asOf": {
                      "type": "integer",
                      "description": "ms since epoch"
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Token contract read failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Token not launched yet",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/token/supply/total": {
      "get": {
        "summary": "Total supply (minted minus burned) as plain text",
        "operationId": "getTokenSupplyTotal",
        "responses": {
          "200": {
            "description": "Total supply (minted minus burned) as plain text",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "example": "1000000000"
                }
              }
            }
          },
          "502": {
            "description": "Token contract read failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Token not launched yet",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/token/supply/circulating": {
      "get": {
        "summary": "Circulating supply (total minus team wallets) as plain text",
        "operationId": "getTokenSupplyCirculating",
        "responses": {
          "200": {
            "description": "Circulating supply (total minus team wallets) as plain text",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "example": "1000000000"
                }
              }
            }
          },
          "502": {
            "description": "Token contract read failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Token not launched yet",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "GpuId": {
        "type": "string",
        "enum": [
          "B300",
          "B200",
          "H200",
          "H200_NVL",
          "H100_SXM",
          "H100_PCIE",
          "H100_NVL",
          "A100_SXM",
          "A100_PCIE",
          "A100_40G",
          "MI300X",
          "L40S",
          "L40",
          "A40",
          "RTX_PRO_6000",
          "RTX6000_ADA",
          "RTX5090",
          "RTX4090",
          "RTX3090"
        ]
      },
      "CatalogGpu": {
        "type": "object",
        "properties": {
          "id": {
            "$ref": "#/components/schemas/GpuId"
          },
          "label": {
            "type": "string"
          },
          "vram": {
            "type": "integer",
            "description": "GB"
          },
          "tier": {
            "type": "string",
            "enum": [
              "datacenter",
              "workstation",
              "consumer"
            ]
          }
        }
      },
      "Provider": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "ok": {
            "type": "boolean"
          },
          "observations": {
            "type": "integer"
          },
          "error": {
            "type": "string"
          }
        }
      },
      "IndexGpu": {
        "type": "object",
        "required": [
          "gpu",
          "index",
          "providers",
          "offers",
          "byProvider"
        ],
        "properties": {
          "gpu": {
            "$ref": "#/components/schemas/GpuId"
          },
          "label": {
            "type": "string"
          },
          "vram": {
            "type": "integer"
          },
          "tier": {
            "type": "string"
          },
          "index": {
            "type": "number",
            "description": "USD per GPU-hour"
          },
          "min": {
            "type": "number"
          },
          "max": {
            "type": "number"
          },
          "providers": {
            "type": "integer"
          },
          "offers": {
            "type": "integer",
            "description": "GPUs listed"
          },
          "available": {
            "type": [
              "integer",
              "null"
            ],
            "description": "GPUs rentable right now; null when no source reports availability"
          },
          "byProvider": {
            "type": "object",
            "additionalProperties": {
              "type": "number"
            }
          },
          "change24h": {
            "type": [
              "number",
              "null"
            ],
            "description": "Percent change vs about 24h ago"
          }
        }
      },
      "Index": {
        "type": "object",
        "properties": {
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "method": {
            "type": "integer"
          },
          "headline": {
            "$ref": "#/components/schemas/GpuId"
          },
          "providers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Provider"
            }
          },
          "gpus": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IndexGpu"
            }
          }
        }
      },
      "History": {
        "type": "object",
        "properties": {
          "gpu": {
            "$ref": "#/components/schemas/GpuId"
          },
          "range": {
            "type": "string"
          },
          "points": {
            "type": "array",
            "items": {
              "type": "array",
              "prefixItems": [
                {
                  "type": "integer",
                  "description": "unix ms"
                },
                {
                  "type": "number",
                  "description": "USD per GPU-hour"
                }
              ]
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          }
        }
      }
    }
  }
}
