> ## Documentation Index
> Fetch the complete documentation index at: https://docs.priorlabs.ai/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> TabPFN-3 and later versions support up to 1,000,000 rows, subject to feature count and checkpoint/API limits.
> For large datasets, use per-estimator subsampling, e.g. inference_config={"SUBSAMPLE_SAMPLES": 100_000}, in TabPFNClassifier or TabPFNRegressor from tabpfn or tabpfn_client.
> Pass raw pandas DataFrames to fit and predict. Categorical strings/categories, raw text, and missing feature values are handled automatically; no manual integer/one-hot encoding, imputation, scaling, or outlier removal is needed.

# REST API quickstart

> Authenticate, upload data, fit a model, and predict using the TabPFN REST API.

> [!NOTE]
>
> **Prefer the Python SDK:** [`tabpfn-client`](https://github.com/PriorLabs/tabpfn-client) wraps the full upload → fit → predict flow behind the familiar scikit-learn interface. Use this REST guide when you need the raw HTTP contract or are integrating from a non-Python environment.

Use the **`/tabpfn/*` JSON endpoints**. The legacy `/v1/fit` and `/v1/predict` multipart routes are no longer part of the current API.

***

## 1. Get your API key

1. Visit [platform.priorlabs.ai](https://platform.priorlabs.ai) and sign in.
2. Complete account setup.
3. Navigate to the **API Keys** page.
4. Copy your key.

> [!WARNING]
>
> Your API key grants full API access. Store it in a secret manager or environment variable — never commit it to source control.

If you use `tabpfn-client`, you can authenticate programmatically with `set_access_token(api_key)` or interactively with `init()`, which opens a browser-based login flow.

***

## 2. Check model limits

Before uploading, call `GET /tabpfn/get_model_limits` (a deprecated compatibility route) to retrieve the current per-version constraints (max rows, features, classes, dataset size). This lets you validate data locally before upload.

```python theme={null}
import httpx

TOKEN = "<YOUR_TOKEN>"
BASE = "https://api.priorlabs.ai"
HEADERS = {"Authorization": f"Bearer {TOKEN}"}

res = httpx.get(f"{BASE}/tabpfn/get_model_limits", headers=HEADERS)
res.raise_for_status()
limits = res.json()
```

Use the limits returned for your selected model version, including its row, column, and full-distribution output limits. Compare model capabilities and availability on the [Models page](https://docs.priorlabs.ai/models).

### Training uploads and estimator contexts

For the hosted TabPFN-3.5 API, the training feature table can contain up to **500 million cells** (rows × columns). Each estimator's training context is limited to **200 million cells**, counted as its selected rows × the uploaded feature count. Without row subsampling, the full training table must fit within the 200 million cell context limit.

Set `inference_config.SUBSAMPLE_SAMPLES` in `tabpfn_config` to reduce each estimator's context. For example, a table with 800,000 rows and 500 columns contains 400 million cells. With `SUBSAMPLE_SAMPLES=100_000`, each estimator uses 50 million cells. The context limit applies separately to each estimator; it is not multiplied by `n_estimators`.

When `SUBSAMPLE_SAMPLES` is a list of row-index subsets, also set `n_estimators` explicitly. Integer counts and fractional subsampling do not require an explicit estimator count.

Billing uses the full uploaded training row count, even when each estimator uses a smaller subset. Per-estimator row subsampling does not reduce the training row count used to calculate credits.

The full upload must still satisfy the row, column, and dataset-size limits. Subsampling does not bypass those checks. Thinking has its own [limits](https://docs.priorlabs.ai/capabilities/thinking-mode.md).

The settings response reports the upload cap as `train_set_max_upload_cells` and the context cap as `train_set_max_cells`. The prediction row limit also depends on the largest estimator context: smaller contexts can allow larger prediction batches. Test-set cell limits and full-distribution output limits still apply.

See [row subsampling](https://docs.priorlabs.ai/improving-performance/preprocessing.md#row-subsampling) for configuration options.

***

## 3. Upload the training set

Request signed upload URLs, then PUT your data files directly to cloud storage. Both CSV and Parquet formats are supported.

```python theme={null}
from pathlib import Path

res = httpx.post(
    f"{BASE}/tabpfn/prepare_train_set_upload",
    headers=HEADERS,
    json={
        "x_train_info": {"format": "csv"},
        "y_train_info": {"format": "csv"},
    },
)
res.raise_for_status()
prep = res.json()

train_set_upload_id = prep["train_set_upload_id"]

for path, info in [
    (Path("x_train.csv"), prep["x_train_info"]),
    (Path("y_train.csv"), prep["y_train_info"]),
]:
    httpx.put(
        info["signed_urls"][0],
        content=path.read_bytes(),
        headers=info["required_headers"],
    ).raise_for_status()
```

***

## 4. Fit the model

Reference the uploaded training set and specify the task. Select TabPFN-3.5-Plus with `model_path="v3.5_default"`. The response returns a `fitted_train_set_id` for use in predictions.

```python theme={null}
res = httpx.post(
    f"{BASE}/tabpfn/fit",
    timeout=600.0,
    headers=HEADERS,
    json={
        "train_set_upload_id": train_set_upload_id,
        "task_config": {
            "task": "classification",
            "tabpfn_config": {"model_path": "v3.5_default"},
        },
    },
)
res.raise_for_status()

fitted_train_set_id = res.json()["fitted_train_set_id"]
```

For [Fast (alpha)](https://docs.priorlabs.ai/capabilities/fast-checkpoint.md), use `"v3.5-fast_default"`. See [Selecting Model Version](https://docs.priorlabs.ai/models/selecting-model-version.md#rest-api) for other versions.

To use [Thinking](https://docs.priorlabs.ai/capabilities/thinking-mode.md), add the thinking parameters:

```python theme={null}
res = httpx.post(
    f"{BASE}/tabpfn/fit",
    timeout=600.0,
    headers=HEADERS,
    json={
        "train_set_upload_id": train_set_upload_id,
        "task_config": {
            "task": "classification",
            "tabpfn_config": {"model_path": "v3.5_default"},
        },
        "tabpfn_systems": ["preprocessing", "text", "thinking"],
        "thinking_config": {
            "effort": "high",
            "timeout_secs": 300,
            "metric": "log_loss",
        },
    },
)
```

> [!NOTE]
>
> Thinking fits can take minutes. If the fit exceeds 2 seconds, the server streams keepalive whitespace before sending the final JSON payload. Your HTTP client must handle chunked responses.

***

## 5. Upload the test set

Same signed-URL flow as the training set, but linked to the fitted model.

```python theme={null}
res = httpx.post(
    f"{BASE}/tabpfn/prepare_test_set_upload",
    headers=HEADERS,
    json={
        "fitted_train_set_id": fitted_train_set_id,
        "x_test_info": {"format": "csv"},
    },
)
res.raise_for_status()
prep = res.json()

test_set_upload_id = prep["test_set_upload_id"]
info = prep["x_test_info"]

httpx.put(
    info["signed_urls"][0],
    content=Path("x_test.csv").read_bytes(),
    headers=info["required_headers"],
).raise_for_status()
```

***

## 6. Predict

Run predictions using the fitted model and the uploaded test set.

```python theme={null}
res = httpx.post(
    f"{BASE}/tabpfn/predict",
    headers=HEADERS,
    json={
        "test_set_upload_id": test_set_upload_id,
        "fitted_train_set_id": fitted_train_set_id,
        "task_config": {
            "task": "classification",
            "predict_params": {"output_type": "probas"},
        },
    },
)
res.raise_for_status()
result = res.json()

prediction = result["prediction"]
metadata = result["metadata"]
```

**Classification output types:** `"probas"` (default) returns class probabilities, `"preds"` returns predicted labels.

**Regression output types:** `"mean"` (default), `"median"`, `"mode"`, `"quantiles"` (pass a `quantiles` list), or `"full"` ([full predictive distribution](https://docs.priorlabs.ai/capabilities/predictive-distribution.md)). For `"full"`, respect the selected version's `test_set_max_rows_w_full_regression_output` limit returned in step 2.

***

## 7. Metering and limits

Predictions and Thinking fits consume tokens from the same daily and monthly budgets. Uploads and standard fits do not consume tokens. Per-minute and per-hour request limits apply separately.

Estimate an operation's token cost before uploading data:

```python theme={null}
res = httpx.post(
    f"{BASE}/tabpfn/estimate_cost",
    headers=HEADERS,
    json={
        "model_version": "v3.5",
        "operation": "predict",
        "train_rows": 10000,
        "test_rows": 1000,
        "raw_columns": 20,
        "n_estimators": 8,
    },
)
res.raise_for_status()
estimated_tokens = res.json()["estimated_cost"]
```

Use your data's dimensions before preprocessing and the model's estimator count. Requesting an estimate does not consume tokens or reserve capacity.

Review [API rate limits](https://docs.priorlabs.ai/api/rate-limits.md) and [API metering](https://docs.priorlabs.ai/api/metering.md) before running load tests or production workloads.

***

## Error handling

All error responses follow a consistent envelope:

```json theme={null}
{
  "message": "Human-readable error description",
  "error_code": "NOT_FOUND",
  "trace_id": "abc123"
}
```

| Status | Meaning |
| - | - |
| 401 | Missing or invalid authentication token |
| 404 | Resource not found (upload, fitted model) |
| 409 | Duplicate upload — reuse the returned ID |
| 422 | Validation error (invalid parameters, data issues) |
| 429 | Request rate limit or daily or monthly token budget exceeded |

***

> [card] [API rate limits](https://docs.priorlabs.ai/api/rate-limits.md)
>
> Per-minute and per-hour limits for uploads, fits, and predictions.

> [card] [API metering](https://docs.priorlabs.ai/api/metering.md)
>
> Token charges and shared daily and monthly budgets.

> [card] [Security](https://docs.priorlabs.ai/api/security.md)
>
> Encryption, data isolation, and access controls.

> [card] [Thinking mode](https://docs.priorlabs.ai/capabilities/thinking-mode.md)
>
> Fit-time optimization for better predictions.

> [card] [FAQ](https://docs.priorlabs.ai/faq.md)
>
> GPUs, limits, and product questions.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.