{
  "openapi": "3.1.0",
  "info": {
    "title": "Dasha Compute API",
    "version": "0.1.0",
    "description": "OpenAI-compatible inference on community Macs; every completed job gets a signed receipt on a public chain. Brain: gateway + Hosted Ask + receipt chain. Hands: Community Macs. Files: Drives (R2 binding DRIVES). Dream: POST /compute/api/v1/drives/{id}/dream via Hosted Ask. Observed from live traffic Sep 11-12, 2026; adopted and verified by the impl lane Sep 14, 2026."
  },
  "servers": [
    {
      "url": "https://lobby.getdasha.com",
      "description": "recommended for interactive (chat, keys); all endpoints answer on both hosts"
    },
    {
      "url": "https://www.getdasha.com",
      "description": "recommended for read-only verification + network state"
    }
  ],
  "paths": {
    "/compute/api/guest-keys": {
      "post": {
        "summary": "Mint a 24h guest key (3/hour/IP)",
        "responses": {
          "201": {
            "description": "Key minted. Response also carries status/reason/hint/next/mint/name/prefix/note fields. Save api_key now; only its hash is stored. Guest keys serve /v1/chat/completions and /v1/models; other inference endpoints 403 guest_key_scope. Drives accept the same dgk_.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "api_key": {
                      "type": "string",
                      "example": "dgk_xxx.yyy"
                    },
                    "id": {
                      "type": "string"
                    },
                    "expires_at": {
                      "type": "integer",
                      "format": "epoch-ms"
                    },
                    "ttl_seconds": {
                      "type": "integer",
                      "example": 86400
                    },
                    "scopes": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "enum": [
                          "chat",
                          "models"
                        ]
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/compute/api/v1/models": {
      "get": {
        "summary": "List models (community + hosted). No auth required.",
        "responses": {
          "200": {
            "description": "OpenAI-style model list"
          }
        }
      }
    },
    "/compute/api/v1/chat/completions": {
      "post": {
        "summary": "Chat completion; completed jobs return an inline receipt record (pending operator settlement)",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Optional. Repeating a request with the same key returns the original job's recorded outcome; never charges twice.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "messages"
                ],
                "properties": {
                  "model": {
                    "type": "string",
                    "example": "qwen3-4b"
                  },
                  "messages": {
                    "type": "array",
                    "description": "1-12 user/assistant messages, max 2000 chars each, 6000 total",
                    "items": {
                      "type": "object"
                    }
                  },
                  "max_tokens": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 4096,
                    "default": 512
                  },
                  "temperature": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 2,
                    "default": 0.6
                  },
                  "drive_id": {
                    "type": "string",
                    "description": "Optional drv_ id recorded on the job and receipt when a Mac runs it. Also accepted as metadata.drive_id. Does not put a Mac online. The kit does not pull the drive."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OpenAI chat completion + job_id + inline receipt record (pending operator settlement; attestation may be null while the operator signs)"
          },
          "401": {
            "description": "invalid_api_key"
          },
          "400": {
            "description": "invalid_messages | unsupported_model | invalid_drive_id | tools/tool_choice present (tools unsupported - fail-loud)"
          },
          "402": {
            "description": "spend limit"
          },
          "409": {
            "description": "one queued job per key"
          },
          "429": {
            "description": "per-key rate limit; Retry-After + X-RateLimit-Limit/Remaining/Reset headers present"
          },
          "499": {
            "description": "client abort"
          },
          "504": {
            "description": "timeout"
          },
          "503": {
            "description": "no_mac_online (community down) | hosted_offline (hosted model unavailable) - fail-loud",
            "machine-readable": null
          }
        }
      }
    },
    "/compute/api/v1/drives": {
      "post": {
        "summary": "Files. Get-or-create a Drive by name for this key owner. R2 binding DRIVES. Works with providers_online=0.",
        "security": [{ "bearer": [] }],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["name"],
                "properties": {
                  "name": { "type": "string", "example": "agent-workspace" }
                }
              }
            }
          }
        },
        "responses": {
          "201": { "description": "created" },
          "200": { "description": "existing drive for this name + owner" },
          "400": { "description": "invalid_drive_name" },
          "401": { "description": "invalid_api_key" },
          "503": { "description": "drives_unavailable — R2 binding DRIVES is not bound" }
        }
      },
      "get": {
        "summary": "List my Drives. Bearer dsk_ or dgk_.",
        "security": [{ "bearer": [] }],
        "responses": {
          "200": { "description": "object list of drives" },
          "401": { "description": "invalid_api_key" },
          "503": { "description": "drives_unavailable" }
        }
      }
    },
    "/compute/api/v1/drives/{id}": {
      "get": {
        "summary": "Drive metadata. 8 MiB/object, 1 GiB per key owner.",
        "security": [{ "bearer": [] }],
        "parameters": [
          { "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }
        ],
        "responses": {
          "200": { "description": "drive" },
          "401": { "description": "invalid_api_key" },
          "404": { "description": "drive_not_found" },
          "503": { "description": "drives_unavailable" }
        }
      }
    },
    "/compute/api/v1/drives/{id}/objects": {
      "get": {
        "summary": "List objects by prefix. Query prefix=. Object bytes live at .../objects/{path} (PUT, GET, DELETE, 8 MiB cap).",
        "security": [{ "bearer": [] }],
        "parameters": [
          { "name": "id", "in": "path", "required": true, "schema": { "type": "string" } },
          { "name": "prefix", "in": "query", "required": false, "schema": { "type": "string" } }
        ],
        "responses": {
          "200": { "description": "object list" },
          "401": { "description": "invalid_api_key" },
          "503": { "description": "drives_unavailable" }
        }
      }
    },
    "/compute/api/v1/drives/{id}/objects/{path}": {
      "put": {
        "summary": "Write object bytes. Cap 8 MiB. Binding DRIVES.",
        "security": [{ "bearer": [] }],
        "parameters": [
          { "name": "id", "in": "path", "required": true, "schema": { "type": "string" } },
          { "name": "path", "in": "path", "required": true, "schema": { "type": "string" } }
        ],
        "responses": {
          "201": { "description": "created" },
          "200": { "description": "replaced" },
          "413": { "description": "object_too_large | drive_quota" },
          "503": { "description": "drives_unavailable" }
        }
      },
      "get": {
        "summary": "Read object bytes.",
        "security": [{ "bearer": [] }],
        "parameters": [
          { "name": "id", "in": "path", "required": true, "schema": { "type": "string" } },
          { "name": "path", "in": "path", "required": true, "schema": { "type": "string" } }
        ],
        "responses": {
          "200": { "description": "raw bytes" },
          "404": { "description": "object_not_found" }
        }
      },
      "delete": {
        "summary": "Delete an object.",
        "security": [{ "bearer": [] }],
        "parameters": [
          { "name": "id", "in": "path", "required": true, "schema": { "type": "string" } },
          { "name": "path", "in": "path", "required": true, "schema": { "type": "string" } }
        ],
        "responses": {
          "200": { "description": "deleted" },
          "404": { "description": "object_not_found" }
        }
      }
    },
    "/compute/api/v1/drives/{id}/snapshot": {
      "post": {
        "summary": "Metadata-only snapshot id. Does not copy object bytes.",
        "security": [{ "bearer": [] }],
        "parameters": [
          { "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }
        ],
        "responses": {
          "201": { "description": "drive.snapshot" },
          "404": { "description": "drive_not_found" }
        }
      }
    },
    "/compute/api/v1/drives/{id}/dream": {
      "post": {
        "summary": "Dream. Hosted Ask reads memory/ or the whole drive and writes memory/dreamed.json. format md writes memory/dreamed.md. Works with providers_online=0. Fails loud when Workers AI is down.",
        "security": [{ "bearer": [] }],
        "parameters": [
          { "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "format": { "type": "string", "enum": ["json", "md"] }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "drive.dream — route hosted, model gpt-oss-20b" },
          "401": { "description": "invalid_api_key" },
          "404": { "description": "drive_not_found" },
          "502": { "description": "hosted_failed" },
          "503": { "description": "hosted_offline | drives_unavailable" }
        }
      }
    },
    "/compute/api/kit-sig": {
      "get": {
        "summary": "Signed kit installer manifest (dasha.kit-sig.v0): ed25519 over dasha-kit:<version>:<sha256>",
        "responses": {
          "200": {
            "description": "statement + sha256 + sig + signer; verify the sig with /keys.json and the sha256 against the downloaded tar and /compute/kit.json",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/compute/api/verify": {
      "get": {
        "summary": "JSON verdict. Optional lookup param: hash | job_id | request_id (any one)",
        "parameters": [
          {
            "name": "hash",
            "in": "query",
            "description": "receipt hash, job_id, or request_id",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "job_id",
            "in": "query",
            "description": "alias of hash",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "request_id",
            "in": "query",
            "description": "alias of hash",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "settled.verify.v0 - ANCHORED | SELF-CONSISTENT | INVALID + chain state + query result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["schema", "verdict", "chain", "checked_at"],
                  "properties": {
                    "schema": {
                      "const": "settled.verify.v0"
                    },
                    "verdict": {
                      "type": "object",
                      "properties": {
                        "tier": {
                          "enum": ["ANCHORED", "SELF-CONSISTENT", "INVALID"]
                        },
                        "why": {
                          "type": "string"
                        }
                      }
                    },
                    "chain": {
                      "type": "object",
                      "properties": {
                        "length": {
                          "type": "integer"
                        },
                        "tip": {
                          "type": "string"
                        }
                      }
                    },
                    "query": {
                      "type": "string",
                      "description": "echo of the lookup value; present only when a lookup param was given"
                    },
                    "found": {
                      "type": "boolean",
                      "description": "present only when a lookup param was given; true = receipt matched"
                    },
                    "receipt": {
                      "type": "object",
                      "description": "present only when found is true; full receipt with id, engine, tokens, cents, at, job_id, request_id, model, latency_ms, kind, prev_hash, hash, sig, signer"
                    },
                    "checked_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/compute/api/chain": {
      "get": {
        "summary": "Full receipt chain (public)",
        "responses": {
          "200": {
            "description": "receipts[] with job_id, engine, tokens, cents, at, prev_hash, hash, sig, signer, model, latency_ms, kind"
          }
        }
      }
    },
    "/heads": {
      "get": {
        "summary": "Signed heads log (tail). Anchors the chain; see llms.txt for format",
        "responses": {
          "200": {
            "description": "head[] with ts, tip, prev_head_hash, hash, sig, signer"
          }
        }
      }
    },
    "/compute/api/network": {
      "get": {
        "summary": "Live network state (public)",
        "responses": {
          "200": {
            "description": "providers_online, models_available, capacity[] (measured tok/s), jobs_queued, kit_versions"
          }
        }
      }
    },
    "/compute/api/readyz": {
      "get": {
        "summary": "Readiness probe",
        "responses": {
          "200": {
            "description": "ready"
          }
        }
      }
    },
    "/compute/api/healthz": {
      "get": {
        "summary": "Liveness probe (fail-loud alias family of readyz; same 200 JSON, not a 308)",
        "responses": {
          "200": {
            "description": "ok"
          }
        }
      }
    },
    "/compute/api/v1/network": {
      "get": {
        "summary": "Alias of /compute/api/network (same 200 JSON)",
        "responses": {
          "200": {
            "description": "providers_online, models_available, capacity[] (measured tok/s), jobs_queued, kit_versions"
          }
        }
      }
    },
    "/compute/api/models": {
      "get": {
        "summary": "Model catalog door",
        "responses": {
          "308": {
            "description": "permanent redirect to /compute/api/v1/models on the same host"
          }
        }
      }
    },
    "/compute/api/jobs": {
      "get": {
        "summary": "List your jobs (browser session login)",
        "responses": {
          "200": {
            "description": "jobs[] with id, status, model, expires_at"
          },
          "401": {
            "description": "login required"
          }
        }
      }
    },
    "/compute/api/jobs/{id}": {
      "get": {
        "summary": "One job's recorded outcome; browser session, or the Bearer key that owns the job (guest keys included)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "id, status, model, answer, error, queue_position, expires_at; usage/route/settle/receipt when stored"
          },
          "401": {
            "description": "login or owning API key required"
          },
          "404": {
            "description": "job not found (or owned by someone else)"
          }
        }
      }
    },
    "/compute/api/pricing": {
      "get": {
        "summary": "Live pricing",
        "responses": {
          "200": {
            "description": "pricing.compute.v0 - $0.05/successful completion"
          }
        }
      }
    },
    "/heads/checkpoint": {
      "get": {
        "summary": "Signed checkpoint of current head (external-anchor friendly)",
        "responses": {
          "200": {
            "description": "checkpoint JSON"
          }
        }
      }
    },
    "/heads/archive/{date}.json": {
      "get": {
        "summary": "Archived heads for a UTC date",
        "parameters": [
          {
            "name": "date",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "2026-09-12"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "heads[]"
          }
        }
      }
    },
    "/compute/api/receipts": {
      "get": {
        "summary": "Owner view (401 unauthenticated)",
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "401": {
            "description": "owner-only"
          }
        }
      }
    },
    "/keys.json": {
      "get": {
        "summary": "Published verification keys (Ed25519 spki_pem)",
        "responses": {
          "200": {
            "description": "dasha.keys.v0"
          }
        }
      }
    },
    "/compute/api/v1/responses": {
      "post": {
        "summary": "Not implemented (Vercel AI SDK default route) - use /v1/chat/completions",
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "401": {
            "description": "invalid_api_key"
          },
          "403": {
            "description": "guest_key_scope (guest keys are chat + models only)"
          },
          "400": {
            "description": "responses are not supported; use POST /v1/chat/completions"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  }
}