> For the complete documentation index, see [llms.txt](https://docs.zdrive.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zdrive.io/api/reference.md).

# API Reference

All API endpoints are served from the CF Worker. Production base URL: `https://app.zdrive.io`

## Authentication

All authenticated endpoints require these fields in the request body (or headers for vault upload):

| Field          | Type   | Description                            |
| -------------- | ------ | -------------------------------------- |
| `x_wallet`     | string | Wallet address (checksummed)           |
| `x_wallet_sig` | string | ERC-1271 signature of the auth message |
| `x_session`    | string | Session UUID (generated client-side)   |

If wallet auth is omitted or invalid, the request falls back to anonymous session-based access.

***

## POST /v1/chat/completions

Proxy to Chutes.ai TEE inference. Streams the response as SSE.

**Request body** (JSON):

```json
{
  "x_wallet": "0x...",
  "x_wallet_sig": "0x...",
  "x_session": "uuid-v4",
  "model": "deepseek-ai/DeepSeek-V3.1-TEE",
  "messages": [
    { "role": "user", "content": "Hello" }
  ],
  "stream": true
}
```

**Supported models:**

* `deepseek-ai/DeepSeek-V3.1-TEE` (paid)
* `deepseek-ai/DeepSeek-V3.2-TEE` (paid)
* `deepseek-ai/DeepSeek-R1-0528-TEE` (paid)
* `Qwen/Qwen3-32B-TEE` (free + paid)
* `Qwen/Qwen3-235B-A22B-Instruct-2507-TEE` (paid)
* `MiniMaxAI/MiniMax-M2.5-TEE` (free + paid)
* `openai/gpt-oss-120b-TEE` (paid)

**Response:** SSE stream (OpenAI-compatible format)

**Response headers:**

| Header                | Value                                                                               |
| --------------------- | ----------------------------------------------------------------------------------- |
| `X-Zdrive-Model-Used` | Actual model that processed the request (may differ from requested due to fallback) |

**Error codes:**

| Status | Meaning                                       |
| ------ | --------------------------------------------- |
| 401    | No identity (no wallet + no session)          |
| 403    | Datacenter ASN blocked                        |
| 413    | Input too long for tier                       |
| 429    | Rate limit reached                            |
| 503    | All fallback models unavailable / RPC failure |

***

## GET /v1/models

Returns which supported models are currently available on Chutes. Result is cached in KV for 5 minutes.

**Response:**

```json
{ "available": ["deepseek-ai/DeepSeek-V3.1-TEE", "Qwen/Qwen3-32B-TEE"] }
```

***

## GET /v1/attestation/report

Returns TEE attestation evidence for a given model.

**Query params:** `?model=deepseek-ai/DeepSeek-V3.1-TEE`

**Response:**

```json
{
  "gpu_tee_verified": true,
  "fpif_verified": true,
  "model_hash": "0x1a2b3c...",
  "gpu_arch": "BLACKWELL",
  "instance_count": 3,
  "failed_instances": 0
}
```

| Field              | Description                                              |
| ------------------ | -------------------------------------------------------- |
| `gpu_tee_verified` | GPU evidence present (confidential GPU confirmed)        |
| `fpif_verified`    | TDX quote present (Intel TDX enclave confirmed)          |
| `model_hash`       | SHA-256 of the TDX quote — fingerprint of running binary |
| `gpu_arch`         | GPU architecture (e.g. BLACKWELL, HOPPER)                |
| `instance_count`   | Number of live instances serving this model              |

***

## POST /vault/upload

Upload an AES-256-GCM encrypted blob to Arweave via Irys node2. Requires a connected wallet with credits > 0.

**Headers:**

| Header             | Required | Description                                |
| ------------------ | -------- | ------------------------------------------ |
| `x-wallet-address` | Yes      | Wallet address                             |
| `x-wallet-sig`     | Yes      | Auth signature                             |
| `x-wallet-session` | Yes      | Session UUID                               |
| `x-vault-tags`     | No       | JSON array of `{name, value}` Arweave tags |
| `Content-Type`     | Yes      | `application/octet-stream`                 |

**Body:** Raw binary ciphertext

**Response:**

```json
{ "id": "arweave-tx-id" }
```

**Error codes:**

| Status | Meaning                                     |
| ------ | ------------------------------------------- |
| 401    | Missing wallet auth headers                 |
| 402    | Credits required — purchase to unlock vault |
| 403    | Invalid wallet signature                    |
| 502    | Irys upload failed                          |

***

## GET /vault/storage-ready

Check if the operator's Irys node2 account has sufficient balance for uploads.

**Response:**

```json
{ "ready": true }
```

or

```json
{ "ready": false, "reason": "Irys account needs funding" }
```

***

## GET /health

Returns worker status.

**Response:**

```json
{
  "status": "ok",
  "inference_provider": "chutes",
  "inference_auth": "configured",
  "arweave_tx": "PLNL3s9T0...",
  "timestamp": "2026-05-17T12:00:00.000Z"
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.zdrive.io/api/reference.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
