{
  "openapi": "3.1.0",
  "info": {
    "title": "OptimToken Public API",
    "version": "1.0.0",
    "description": "Free, no-auth JSON API behind optimtoken.optimnow.io. Compare LLM API pricing (incl. batch and prompt-cache rates, Arena ELO quality scores) and cloud compute instance pricing across 7 providers.\n\nField provenance is marked in each description: [published] = taken directly from the provider/source API; [derived] = computed from published values with a documented formula; [estimated] = curated fallback value, not a quote.\n\nCitation: when you use this data, cite https://optimtoken.optimnow.io/ as the source. Data is provided as-is for comparison purposes; verify final numbers with official provider pricing pages.",
    "contact": { "name": "OptimNow", "url": "https://www.optimnow.io/contact" },
    "license": { "name": "Free to use with attribution", "url": "https://optimtoken.optimnow.io/llms.txt" }
  },
  "servers": [{ "url": "https://optimtoken.optimnow.io" }],
  "paths": {
    "/api/llm-models": {
      "get": {
        "summary": "LLM pricing catalogue",
        "description": "All tracked LLM models with USD prices per 1 million tokens. Refreshed at most every 24h (CDN cache). Sorted by Arena ELO descending, then release date.",
        "parameters": [
          { "name": "provider", "in": "query", "schema": { "type": "string" }, "description": "Exact provider name, case-insensitive (e.g. Anthropic, OpenAI, Google)." },
          { "name": "model", "in": "query", "schema": { "type": "string" }, "description": "Case-insensitive substring match on the model name (e.g. 'sonnet')." },
          { "name": "limit", "in": "query", "schema": { "type": "integer", "minimum": 1 }, "description": "Maximum number of models returned, applied after filters." }
        ],
        "responses": {
          "200": {
            "description": "Model list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "models": { "type": "array", "items": { "$ref": "#/components/schemas/LLMModel" } },
                    "meta": { "$ref": "#/components/schemas/LLMMeta" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/pricing": {
      "get": {
        "summary": "Cloud compute instance pricing",
        "description": "VM/instance pricing for AWS, Azure, GCP, DigitalOcean, OCI, OVH, and Alibaba Cloud. Live provider APIs where available (see meta.sources), refreshed at most every 24h. Check meta.sourceRegions: some providers' public endpoints return a global list price regardless of the selected region.",
        "parameters": [
          { "name": "region", "in": "query", "schema": { "type": "string", "enum": ["us-east", "us-west", "europe", "asia-pacific"], "default": "us-east" }, "description": "Pricing region. Live providers (AWS, Azure, GCP) are priced in the mapped provider region; static providers are estimated from US East with a regional multiplier: see meta.sourceRegions for the truth per provider." },
          { "name": "provider", "in": "query", "schema": { "type": "string" }, "description": "Comma-separated provider list, case-insensitive (e.g. aws,gcp)." },
          { "name": "instanceType", "in": "query", "schema": { "type": "string" }, "description": "Case-insensitive substring match on the instance type (e.g. 't4g', 'D2s')." },
          { "name": "limit", "in": "query", "schema": { "type": "integer", "minimum": 1 }, "description": "Maximum number of instances returned, applied after filters. Without it the response can exceed 6,000 rows." }
        ],
        "responses": {
          "200": {
            "description": "Instance list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "instances": { "type": "array", "items": { "$ref": "#/components/schemas/ComputeInstance" } },
                    "meta": { "$ref": "#/components/schemas/PricingMeta" }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "LLMModel": {
        "type": "object",
        "properties": {
          "provider": { "type": "string", "description": "[published] Vendor display name (e.g. Anthropic, OpenAI)." },
          "model": { "type": "string", "description": "[published] Model display name (e.g. Claude Sonnet 5)." },
          "parameters": { "type": "string", "description": "[published/estimated] Parameter count where disclosed (e.g. 70B, 1T); curated for major models, extracted from names/descriptions otherwise." },
          "inputPricePer1M": { "type": "number", "description": "[published] USD per 1M input tokens, list price, 4-decimal precision." },
          "outputPricePer1M": { "type": "number", "description": "[published] USD per 1M output tokens, list price." },
          "batchInputPricePer1M": { "type": "number", "description": "[published] Batch API input price where the provider publishes one (typically -50%). Absent = not published." },
          "batchOutputPricePer1M": { "type": "number", "description": "[published] Batch API output price. Absent = not published." },
          "cachedInputPricePer1M": { "type": "number", "description": "[published] Prompt-cache READ price per 1M tokens (typically ~10% of input). Absent = not published." },
          "contextWindow": { "type": "string", "description": "[published] Context window (e.g. 200K, 1M)." },
          "category": { "type": "string", "enum": ["Frontier", "Mid-tier", "Budget", "Image"], "description": "[derived] PRICE TIER ONLY (schemaVersion 2.0+). Image wins first, on output modality; otherwise Frontier at output >= $15/1M or input >= $10/1M, Mid-tier at output >= $2/1M, Budget below. BREAKING in 2.0: the 'Open Weights' value was removed. It conflated deployment freedom with price, so open-licensed models were split arbitrarily between it and the price tiers. Openness is now a separate axis derived from `license`: Apache 2.0 and MIT are open source; Llama 3.x, Gemma, Qwen, Mistral, CC-BY-NC-4.0 and Modified MIT are open weights; Proprietary is API-only; anything absent or unrecognised is unknown. A model can be frontier-priced AND open-weight." },
          "capabilities": { "type": "array", "items": { "type": "string" }, "description": "[derived] From published modalities and supported parameters (Text, Vision, Code, Reasoning, Agents, Image Gen, Audio)." },
          "releaseDate": { "type": "string", "description": "[published/estimated] YYYY-MM. Curated for major models; otherwise the source catalogue's listing date." },
          "eloScore": { "type": "number", "description": "[published] Arena (ex-LMArena) ELO, hand-refreshed monthly; post-Jan-2026 recalibrated scale for 2025+ models. See meta.eloAsOf for the snapshot date. Absent = not ranked." },
          "license": { "type": "string", "description": "[derived] License family, from an exact-model override where one is recorded, otherwise inferred from the vendor (Proprietary, Apache 2.0, Llama 3.x, ...). Absent = never established, which is NOT the same as proprietary: do not present a missing license as closed. Vendor-level inference cannot represent a lab that ships a mix of open and closed models, so treat an uncorroborated 'Proprietary' on a lab known to publish weights as unconfirmed." }
        },
        "required": ["provider", "model", "inputPricePer1M", "outputPricePer1M", "contextWindow", "category", "capabilities"]
      },
      "LLMMeta": {
        "type": "object",
        "properties": {
          "schemaVersion": { "type": "string" },
          "total": { "type": "integer", "description": "Models returned after filters." },
          "catalogTotal": { "type": "integer", "description": "Models in the full catalogue." },
          "source": { "type": "string", "description": "openrouter = live upstream; error = upstream unavailable (clients fall back to a static snapshot)." },
          "timestamp": { "type": "string", "format": "date-time", "description": "When this response snapshot was generated." },
          "eloAsOf": { "type": "string", "description": "Date of the last Arena ELO refresh (YYYY-MM-DD)." }
        }
      },
      "ComputeInstance": {
        "type": "object",
        "description": "null in any price field means the provider does not offer that pricing tier for this instance.",
        "properties": {
          "provider": { "type": "string", "enum": ["AWS", "Azure", "GCP", "DigitalOcean", "OCI", "OVH", "Alibaba"] },
          "instanceType": { "type": "string", "description": "[published] Provider's instance/shape name." },
          "os": { "type": "string", "enum": ["Linux", "Windows"] },
          "vCPUs": { "type": "number", "description": "[published]" },
          "memory": { "type": "number", "description": "[published] GiB." },
          "onDemandHourly": { "type": ["number", "null"], "description": "[published] USD/hour, on-demand list price." },
          "onDemandMonthly": { "type": ["number", "null"], "description": "[derived] onDemandHourly x 730." },
          "spot": { "type": ["number", "null"], "description": "[published] Spot/preemptible USD/hour. Exception OCI: [derived] 50% of on-demand (OCI's fixed policy)." },
          "savingsPlan1yr": { "type": ["number", "null"], "description": "[published] 1-year savings plan / CUD effective hourly, no upfront where the provider offers it." },
          "savingsPlan3yr": { "type": ["number", "null"], "description": "[published] 3-year savings plan / CUD effective hourly." },
          "reserved1yr": { "type": ["number", "null"], "description": "[derived] 1-year reservation as an EFFECTIVE HOURLY rate. Azure reservations are term purchase totals divided by 8,760 hours; AWS reserved is the published no-upfront hourly rate." },
          "reserved3yr": { "type": ["number", "null"], "description": "[derived] 3-year reservation, effective hourly (term total / 26,280 hours for Azure)." }
        },
        "required": ["provider", "instanceType", "os", "vCPUs", "memory"]
      },
      "PricingMeta": {
        "type": "object",
        "properties": {
          "schemaVersion": { "type": "string", "description": "1.1 adds meta.priceTypes (per-column provenance). 1.2 adds meta.liveProviders." },
          "region": { "type": "string", "description": "Requested region slug." },
          "timestamp": { "type": "string", "format": "date-time" },
          "sources": { "type": "object", "description": "Per provider: live (fetched from the provider API this cycle) or static (curated fallback)." },
          "sourceRegions": { "type": "object", "description": "Per provider, the region actually priced: a region label for live region-resolved providers; 'global list price (availability varies by region)' for providers whose public endpoint is not regional (DigitalOcean, OCI, OVH); '[estimated: US East x multiplier]' for static fallbacks." },
          "priceTypes": { "type": "object", "description": "Per provider, the provenance of EACH price column, finer-grained than meta.sources: { onDemand, spot, savingsPlan1yr, savingsPlan3yr, reserved1yr, reserved3yr } each set to 'live' (some row for that provider carried a value fetched from the provider API this cycle), 'static' (values exist but are a curated estimate back-filled from the built-in catalogue, NOT fetched live), or 'unavailable' (no value at all: the provider does not sell that pricing model, or it is not modelled). A provider can be 'live' in meta.sources while a single column is 'static'; as of schemaVersion 1.1 that is the case for AWS savingsPlan1yr/3yr and GCP savingsPlan1yr/3yr (CUD). Do not present a 'static' column as live provider data.", "additionalProperties": { "type": "object", "properties": { "onDemand": { "type": "string", "enum": ["live", "static", "unavailable"] }, "spot": { "type": "string", "enum": ["live", "static", "unavailable"] }, "savingsPlan1yr": { "type": "string", "enum": ["live", "static", "unavailable"] }, "savingsPlan3yr": { "type": "string", "enum": ["live", "static", "unavailable"] }, "reserved1yr": { "type": "string", "enum": ["live", "static", "unavailable"] }, "reserved3yr": { "type": "string", "enum": ["live", "static", "unavailable"] } } } },
          "liveProviders": { "type": "object", "description": "How much of this response is live (schemaVersion 1.2+): { live, expected } counted over the six live-capable providers (AWS, Azure, GCP, DigitalOcean, OCI, OVH; Alibaba is static by design). When live < expected, part of the catalogue is a curated static estimate and the response is cached for minutes rather than a day. Treat a heavily degraded response as provisional.", "properties": { "live": { "type": "integer" }, "expected": { "type": "integer" } } },
          "total": { "type": "integer", "description": "Instances returned after filters." },
          "catalogTotal": { "type": "integer", "description": "Instances in the full merged catalogue for this region." },
          "errors": { "type": "array", "items": { "type": "string" }, "description": "Non-fatal fetch errors (a provider falling back to static)." }
        }
      }
    }
  }
}
