{
  "openapi": "3.1.0",
  "info": {
    "title": "LLM TimeMachine Developer API",
    "version": "1.0.0",
    "summary": "Read-only JSON API over the public archive of LLM TimeMachine.",
    "description": "A read-only JSON API over the public archive of LLM TimeMachine: public capsules (frozen prompts) and every run of them across AI models, with the output, cost, latency and token counts. No account or key needed.\n\nResponses may be cached for up to 60 seconds. CORS is open. Launching runs is not part of this API.",
    "contact": {
      "name": "LLM TimeMachine",
      "url": "https://llmtimemachine.com/developers"
    }
  },
  "externalDocs": {
    "description": "Developer documentation",
    "url": "https://llmtimemachine.com/developers"
  },
  "servers": [
    {
      "url": "https://llmtimemachine.com",
      "description": "Production"
    }
  ],
  "security": [],
  "tags": [
    {
      "name": "Meta",
      "description": "About the API itself."
    },
    {
      "name": "Capsules",
      "description": "Public capsules: frozen prompts."
    },
    {
      "name": "Runs",
      "description": "Runs of a public capsule: one model answering its prompt."
    }
  ],
  "paths": {
    "/api/v1": {
      "get": {
        "operationId": "getApiIndex",
        "tags": [
          "Meta"
        ],
        "summary": "API index",
        "description": "The API version, and links to the endpoints and to this specification.",
        "responses": {
          "200": {
            "description": "The API index.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiIndex"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/capsules": {
      "get": {
        "operationId": "listCapsules",
        "tags": [
          "Capsules"
        ],
        "summary": "List public capsules",
        "description": "Public capsules, most recently active first (their last completed run, else their creation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/CapsulesLimit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of public capsules.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CapsulePage"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/v1/capsules/{id}": {
      "get": {
        "operationId": "getCapsule",
        "tags": [
          "Capsules"
        ],
        "summary": "Get a public capsule",
        "description": "One public capsule, with its frozen prompt. A private or unknown capsule answers 404.",
        "parameters": [
          {
            "$ref": "#/components/parameters/CapsuleId"
          }
        ],
        "responses": {
          "200": {
            "description": "The capsule.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Capsule"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/v1/capsules/{id}/runs": {
      "get": {
        "operationId": "listCapsuleRuns",
        "tags": [
          "Runs"
        ],
        "summary": "List a public capsule's runs",
        "description": "The runs of a public capsule, oldest first, as its timeline shows them. Runs the owner hid are left out.",
        "parameters": [
          {
            "$ref": "#/components/parameters/CapsuleId"
          },
          {
            "$ref": "#/components/parameters/RunsLimit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of runs.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RunPage"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    }
  },
  "components": {
    "parameters": {
      "CapsuleId": {
        "name": "id",
        "in": "path",
        "required": true,
        "description": "The capsule id (a UUID).",
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "CapsulesLimit": {
        "name": "limit",
        "in": "query",
        "required": false,
        "description": "How many capsules to return.",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100,
          "default": 20
        }
      },
      "RunsLimit": {
        "name": "limit",
        "in": "query",
        "required": false,
        "description": "How many runs to return.",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 50,
          "default": 20
        }
      },
      "Offset": {
        "name": "offset",
        "in": "query",
        "required": false,
        "description": "How many items to skip.",
        "schema": {
          "type": "integer",
          "minimum": 0,
          "default": 0
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "A parameter is not valid.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "status": 400,
                "message": "limit must be an integer between 1 and 100"
              }
            }
          }
        }
      },
      "NotFound": {
        "description": "No public capsule has this id.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "status": 404,
                "message": "Capsule not found"
              }
            }
          }
        }
      },
      "Unavailable": {
        "description": "The archive could not be reached.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "status": 503,
                "message": "The archive could not be reached, try again shortly"
              }
            }
          }
        }
      }
    },
    "schemas": {
      "ApiIndex": {
        "type": "object",
        "required": [
          "name",
          "version",
          "description",
          "documentation",
          "openapi",
          "endpoints"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "documentation": {
            "type": "string",
            "format": "uri"
          },
          "openapi": {
            "type": "string",
            "format": "uri"
          },
          "endpoints": {
            "type": "object",
            "required": [
              "capsules",
              "capsule",
              "runs"
            ],
            "properties": {
              "capsules": {
                "type": "string"
              },
              "capsule": {
                "type": "string",
                "description": "URI template."
              },
              "runs": {
                "type": "string",
                "description": "URI template."
              }
            }
          }
        }
      },
      "Author": {
        "type": "object",
        "required": [
          "username"
        ],
        "properties": {
          "username": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "CapsuleSummary": {
        "type": "object",
        "required": [
          "id",
          "title",
          "url",
          "api_url",
          "runs_url",
          "category",
          "capsule_type",
          "capsule_mode",
          "prompt_type",
          "author",
          "created_at",
          "last_run_at",
          "runs_count",
          "models_count"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "title": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "The capsule page on the site."
          },
          "api_url": {
            "type": "string",
            "format": "uri",
            "description": "This capsule in the API."
          },
          "runs_url": {
            "type": "string",
            "format": "uri",
            "description": "Its runs in the API."
          },
          "category": {
            "type": [
              "string",
              "null"
            ]
          },
          "capsule_type": {
            "type": "string",
            "enum": [
              "chat",
              "agentic"
            ],
            "description": "chat: a model answers. agentic: a model works in a sandbox and produces files."
          },
          "capsule_mode": {
            "type": "string",
            "enum": [
              "compare",
              "chain"
            ],
            "description": "compare: every run answers the prompt from scratch. chain (a Relay): each run improves the version before it."
          },
          "prompt_type": {
            "type": "string",
            "enum": [
              "text",
              "image",
              "audio",
              "video"
            ]
          },
          "author": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Author"
              },
              {
                "type": "null"
              }
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "last_run_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Last completed run, null when it never had one."
          },
          "runs_count": {
            "type": "integer",
            "minimum": 0,
            "description": "Completed runs."
          },
          "models_count": {
            "type": "integer",
            "minimum": 0,
            "description": "Distinct models among the completed runs."
          }
        }
      },
      "Capsule": {
        "allOf": [
          {
            "$ref": "#/components/schemas/CapsuleSummary"
          },
          {
            "type": "object",
            "required": [
              "prompt_content",
              "system_prompt_template",
              "brief",
              "is_locked",
              "retained_run_id"
            ],
            "properties": {
              "prompt_content": {
                "type": "string",
                "description": "The frozen prompt, sent as is to every model."
              },
              "system_prompt_template": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "System prompt sent ahead of the prompt, frozen with it. May hold {{VAR:MODEL_ID}} and {{VAR:RUN_DATE}}, filled in on each run."
              },
              "brief": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The owner's description of the capsule, in Markdown."
              },
              "is_locked": {
                "type": "boolean",
                "description": "A capsule locks on its first run: its prompt can never change again."
              },
              "retained_run_id": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uuid",
                "description": "On a Relay, the version the owner keeps."
              }
            }
          }
        ]
      },
      "AttemptTotals": {
        "type": "object",
        "required": [
          "latency_ms",
          "cost_usd",
          "prompt_tokens",
          "completion_tokens",
          "total_tokens"
        ],
        "properties": {
          "latency_ms": {
            "type": [
              "integer",
              "null"
            ]
          },
          "cost_usd": {
            "type": [
              "number",
              "null"
            ],
            "description": "US dollars."
          },
          "prompt_tokens": {
            "type": [
              "integer",
              "null"
            ]
          },
          "completion_tokens": {
            "type": [
              "integer",
              "null"
            ]
          },
          "total_tokens": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      },
      "Run": {
        "type": "object",
        "required": [
          "id",
          "model_id",
          "resolved_model",
          "output_type",
          "output_text",
          "image_url",
          "latency_ms",
          "cost_usd",
          "prompt_tokens",
          "completion_tokens",
          "total_tokens",
          "reasoning_tokens",
          "attempts",
          "reasoning_text",
          "web_search_used",
          "created_at",
          "run_origin",
          "status",
          "parent_run_id"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "model_id": {
            "type": "string",
            "description": "The model asked, as an OpenRouter id."
          },
          "resolved_model": {
            "type": [
              "string",
              "null"
            ],
            "description": "The model that answered, when the provider reported it."
          },
          "output_type": {
            "type": "string",
            "enum": [
              "text",
              "image"
            ]
          },
          "output_text": {
            "type": [
              "string",
              "null"
            ]
          },
          "image_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "The generated image, when output_type is image."
          },
          "latency_ms": {
            "type": [
              "integer",
              "null"
            ]
          },
          "cost_usd": {
            "type": [
              "number",
              "null"
            ],
            "description": "US dollars."
          },
          "prompt_tokens": {
            "type": [
              "integer",
              "null"
            ]
          },
          "completion_tokens": {
            "type": [
              "integer",
              "null"
            ]
          },
          "total_tokens": {
            "type": [
              "integer",
              "null"
            ]
          },
          "reasoning_tokens": {
            "type": [
              "integer",
              "null"
            ]
          },
          "attempts": {
            "type": "integer",
            "minimum": 1,
            "description": "How many times the model was called for this answer. The figures are those of the first attempt."
          },
          "all_attempts": {
            "$ref": "#/components/schemas/AttemptTotals",
            "description": "Totals of every attempt; present only when attempts is above 1, or when the turns cannot be told apart."
          },
          "reasoning_text": {
            "type": [
              "string",
              "null"
            ]
          },
          "web_search_used": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "run_origin": {
            "type": "string",
            "enum": [
              "browser",
              "agentic",
              "mcp"
            ],
            "description": "Where the run was made. mcp: in a client such as Claude Code, on its user's own subscription; the model and the answer are declared by the client, cost_usd is null."
          },
          "tokens_estimated": {
            "type": "boolean",
            "description": "MCP runs only: the token counts are estimated from the text (no exact count was sent by the client)."
          },
          "api_equivalent_cost_usd": {
            "type": [
              "number",
              "null"
            ],
            "description": "MCP runs only: what the answer would cost through the API at the catalog price. Never billed."
          },
          "status": {
            "type": "string",
            "enum": [
              "completed",
              "failed",
              "timed_out",
              "running",
              "queued"
            ]
          },
          "parent_run_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "On a Relay, the version this step improved."
          }
        }
      },
      "Pagination": {
        "type": "object",
        "required": [
          "limit",
          "offset",
          "total",
          "next"
        ],
        "properties": {
          "limit": {
            "type": "integer",
            "minimum": 1
          },
          "offset": {
            "type": "integer",
            "minimum": 0
          },
          "total": {
            "type": "integer",
            "minimum": 0
          },
          "next": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "description": "URL of the next page, null on the last one."
          }
        }
      },
      "CapsulePage": {
        "type": "object",
        "required": [
          "data",
          "pagination"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CapsuleSummary"
            }
          },
          "pagination": {
            "$ref": "#/components/schemas/Pagination"
          }
        }
      },
      "RunPage": {
        "type": "object",
        "required": [
          "data",
          "pagination"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Run"
            }
          },
          "pagination": {
            "$ref": "#/components/schemas/Pagination"
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "status",
              "message"
            ],
            "properties": {
              "status": {
                "type": "integer"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}